I have 2 tables
update 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.RECID
WHERE cobros.ACCOUNTNUM =(Select cobros2.ACCOUNTNUM FROM cobros2 WHERE cobros2.RECID = @GetRECID)
AND Cobros.RECID <> @GetRECID
cobros vencidos
------- ------
ACCOUNTNUM RECID ID COMENTARIO
00015 354 354 .....
00015 275 275 bla bla
00015 112 765 .....
example:
@GetRECID = 275
The 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 = 275
COBROS: go to the record where RECID = 275 -> ACCOUNTNUM = 00015
COBROS: Get all records where ACCOUNTNUM = 00015 -> take their RECID
VENCIDOS: Get all records with these found RECID that match ID
VENCIDOS: UPDATE these records with the content of the columns (comentario, status,..) for the record where ID = 275 = @GetRECID
The update would just affect one record:
VENCIDOS
ID COMENTARIO
--- ---------
354 bla bla
I 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