I have 4 MySQL tables
folder, folder_users, folder_posts, posts
I need to build a view which queries the above and returns data which I can the filter based on a user id
folder has:
id, userid, title, date
folder_users has:
id, folderid, userid
folder_posts has:
id, folderid, postid
posts has:
id, userid, media, text, type
The aim is to display a set of folders to a logged in user where they have access to the folder and that shows the latest image (held in media column on posts table) ideally I would like to get this into a MySQL View and have it ordered by folder.date
I am struggling as where to start with this query so any help would be really great thanks.
* EDIT just thought of a missing element **
The posts table will have other type of posts that will mean that some posts in a folder may have no media, so the query needs to compensate for this i.e. where there is media make sure that this included in the result and where no media then don’t
1 Answer