I want to show the last user action. (you can read my last question for more info on this)
I need to make a big JOIN (6+ tables).
I need to get only one row per identifier, but there are several tables containing more than one row per identifier. For example, an article identifier can contain only one row in the “votes” table, but there can be many “images” in the table, because there can be more than one image in one article, but I need only one image.
So I need to do something like this (of course, this code is incorrect):
SELECT table1.item, table2.item, table3.item, table4.item, table5.item
FROM table1
LEFT OUTER JOIN ... ON ... AND ...
LEFT OUTER JOIN ... ON ... AND ...
LEFT OUTER JOIN ... ON ... AND ... LIMIT 1
LEFT OUTER JOIN ... ON ... AND ... LIMIT 1
WHERE table1.item = ?;
How can i do this?