Originally Posted by Old Pedant
First of all, *NEVER* use SELECT *
, and that's especially important when you want to select values based on conditions.
It would have helped if you had simply told us what you wanted to see for the record with id 12165.
This IF makes no sense to me:
IF(st.shared_from_id is null, st.user_id=4310, st.id=st.shared_from_id)
That seems to say that if shared_from_id IS NULL, then the user_id remains untouched. But if it is not null, then the ID itself--not the user_id--is changed. Meaning that no matter what the user_id will be 4310. HUH?
Did you want to see
id user_id status shared_from_id
12164 4310 xxxxxx 12164
I meaned it like: select from statuses where if shared from id is null *use the user id*, else *select the id of the owner of shared status so where the status.id = 12164(shared_from_id)*