Originally Posted by Old Pedant
I *THINK* what you want is this:
SELECT IFNULL(s2.id,s1.id) AS effectiveID, IFNULL(s2.status, s1.status) AS effectiveStatus
FROM statuses AS s1
LEFT JOIN statuses AS s2 ON s2.id = s1.shared_from_id
WHERE s1.user_id = 4310
ORDER BY effectiveID DESC
Given data like this:
12165 4310 status12165 12164
12164 25 status12164 null
12163 4310 status12163 null
I believe that query would output
which I *think* is what you want. No?
yea exactly! you are genious nice! self join came to mind me too but i didnt know how to write it. And now when i want to display all other fields how to do that? its prety large table so ... should i allways... IFNULL(etc etc ) ?