I currently have this
SELECT *
FROM images
WHERE images.id IN (SELECT image_id FROM image_likes WHERE user_id = '1')
UNION
SELECT *
FROM images
WHERE images.user_id = '1' AND upload_type in (4,3) ORDER BY id DESC
And this works great, but now i want it to display the most recent results thats have happend.
For example, User A uploaded a image-> information goes into images with a timestamp. User A then likes someone else’s image -> Information goes into image_likes with a timestamp. Now how would i make the two timestamp column’s merge together so i can sort them by DESC.
Breif run over of what the query does.
Selects the image information from images where the user has liked a image in image_likes and then it grabs all of the uploads the user has uploaded from images and merges them into a query. What i need is to be able to sort them using the timestamp from both tables.
how about doing this??
OR even better
chk this http://dev.mysql.com/doc/refman/5.5/en/union.html
UPDATE
TRY THIS
UPDATE
Final query as per your requirement