I have 2 tablesupdate vencidas SET [comentario] = a.comentario, [Status] = a.Status, ... from (select ID, comentario, Status, ... from vencidas where ID=@GetRECID) a LEFT OUTER JOIN cobros ON A.ID = cobros.RECIDWHERE cobros.ACCOUNTNUM =(Select cobros2.ACCOUNTNUM FROM cobros2 WHERE cobros2.RECID = @GetRECID) AND Cobros.RECID <> @GetRECIDcobros vencidos ------- ------ACCOUNTNUM RECID ID COMENTARIO00015 354 354 .....00015 275 275 bla bla00015 112 765 .....
example:@GetRECID = 275The update command should achieve that in vencidos those records are update, that do have a match for RECID = ID considering ONLY those records with ACCOUNTNUM 00015.or in a discriptive way:@GetRECID = 275COBROS: go to the record where RECID = 275 -> ACCOUNTNUM = 00015COBROS: Get all records where ACCOUNTNUM = 00015 -> take their RECIDVENCIDOS: Get all records with these found RECID that match IDVENCIDOS: UPDATE these records with the content of the columns (comentario, status,..) for the record where ID = 275 = @GetRECIDThe update would just affect one record:VENCIDOSID COMENTARIO--- ---------354 bla blaI really dont understand why my query doesn't find any records to update; I can't see the mistake, but no record is found to apply the update too.My head is bursting,Thanks,Martin