I know this very silly, but can anybody help me in understanding what does this join query is doing in elabortive description?
SELECT j1.*
FROM jos_audittrail j1
LEFT OUTER JOIN jos_audittrail j2
ON (j1.trackid = j2.trackid AND j1.field = j2.field AND j1.changedone < j2.changedone)
WHERE j1.operation = 'UPDATE'
AND j1.trackid=$t_ids[$n]
AND j2.id IS NULL
I know its very silly, but i need to go ahead with my further need… Pls do help me…
The
Left Joinin combination withj2.id IS NULLreturns only those rows ofj1, where no row ofj2can be found.Since the condition is
j1.changedone < j2.changedone, it returns only the rows with the highestchangedonepertrackid(if there is more than one row with this value ofchangedonefor atrackid, all of them are returned).So if you have
You will get
since for
1 - 1theLeft Joinfinds a record (1 - 2), soj2.idisNOT NULL.