SELECT 'Q' AS TYPE,
q.question AS value,
q.date
FROM questions q
WHERE q.user_id =39
UNION ALL
SELECT 'A' AS TYPE,
q.question AS value,
a.date
FROM answers a,
questions q
WHERE a.question_id = q.id
AND WHERE a.user_id =39
ORDER BY `date` DESC
database design:
- questions{id,user_id,question,date}
- answers{id,question_id,user_id,answer,date}
error:
1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE a . user_id = 39 ORDER BY
dateDESC
There are two WHERE-clauses in the lower part of the query. You need to literally remove just the last word WHERE. The error description is all you need.