I need to delete data from two tables whenever they are older than a given date. The tables are the following:
Table: reservation
| id | contrato_id | fecha | ...
Table: contract
| id | tipo | precio_total | ...
Are related by the contract ID: in the reservation table (contract_id) and in the contract table (id).
The query I have so far is:
DELETE * FROM reserva as s INNER JOIN contrato as c ON s.contrato_id=c.id WHERE s.fecha < "'. $fecha_limite .'";
The problem is that both tables do not have the same number of records and this query does not work for me, it only deletes records if they have a contract done. But it may be the case that there are reserves without contract_id because it has not yet been created. How can I solve it?