I know that join queries must have the same number of columns. I am trying to get results from a table commentsand results from a table stringsthat has multiple joins. How is that right? I have not tested yet, because I know that I am getting an error with a different number of columns. Here are two queries I'm trying to combine.
query 1 (rows)
SELECT sub.actionid as usersub,
ftable.`last-time` as lastvisited, updatetable.recent as mostrecent, parent.* FROM `strings` as parent
LEFT JOIN subscribe sub on sub.actionid=parent.id AND sub.userid=:userid
JOIN followers ftable on ((ftable.sid=parent.sid AND ftable.page='1') OR
(ftable.sid=parent.sid AND ftable.position=parent.position AND ftable.page='0')
OR (ftable.profile=parent.starter AND parent.guideline='1')) AND ftable.userid=:userid
JOIN `update-recent` updatetable on
((updatetable.sid=parent.sid AND updatetable.position=parent.position AND updatetable.pageid='0')
OR (updatetable.profile=parent.starter) OR (updatetable.pageid=parent.pageid AND parent.pageid!=0))
WHERE ftable.userid=:userid AND parent.deleted='0' GROUP BY parent.id
request 2 (comments)
SELECT * FROM comments WHERE viewed='0' AND (`starter-id`=:userid OR respondid=:userid)
I would like to order the results on the timestamp column posted(most recent)ORDER BY posted DESC
How to combine these queries?
source
share