Tables:
items -> id, userId, tagId, postedOn
itemsTags -> id, name
users -> id, firstName, lastName
usersFriends -> id, userId, friendUserId
The system needs a re-build, at the moment the flow is like this:
- Get all the friends of the user.
- Per friend (foreach) get the items the friend posted.
- Get the tag data of the item (tagId).
- Get the user data of the item (userId).
But the problem is, I need to sort it by date, and later on by a specific date for example, I want to see all the items of my friends that where posted today so I need a query that does those 4 queries in one, so basically SELECT * FROM usersFriends JOIN items ON userId ...
I just can’t figure out the rest.
Where on the questionmarks you place the user’s id.