I have the follow query:
SELECT pro.*
FROM tb_AutProposta pro, tb_AutParcelamento par
WHERE pro.id = par.id
But, want to limit each tb_AutParcelamento to 1. Tried “Subselect”, but without success.
The table pro is an contract and par is the parcels of this contract. For each contract, is generated n parcels, and, for each parcel is generated a due date, and I need to know the last due date for each contract.
Any idea?
I just made up some field names because we don’t know your exact table structure.
This query works under the assumptions:
due_dateandpro_idin your parcel table. (tb_AutParcelamento.pro_idbeing a foreign key to thetb_AutProposta.id)pro_idbecause i assume the conditionpro.id = par.idis wrong, when theidfields in both tables are auto increment values and the primary key in each table.