I have a MySQL database with a photos table (containing the photos) and a follows table (containing information about users following users).
I have the following code to load photos from the users that the current user is following:
SELECT photos.* FROM photos,follows
WHERE follows.following = photos.uid AND
follows.follower=$current_uid
ORDER BY photos.id DESC
I want to load a list of both my user’s uploaded photos as well as the ones that user is following. I tried the following, but I keep getting a whole bunch of duplicate entries:
SELECT photos.*
FROM photos,follows
WHERE (follows.following = photos.uid AND
follows.follower=$current_uid) OR
photos.uid=$current_uid
ORDER BY photos.id DESC
Can anyone help with this?
Try this:
Alternatively: