SQL: union operator

An UNION operator must have an equal number of columns in the SELECT:

(SELECT *, t.table_id, t.title, t.description
FROM TABLE t
LEFT JOIN jointable jt ON t.table_id=jt.table_id
WHERE t.status=1
GROUP BY t.table_id
ORDER BY description)
UNION (SELECT *, t.table_id, t.title, t.description
FROM TABLE t
LEFT JOIN jointable jt ON t.table_id=jt.table_id
WHERE t.user_id=1)

Leave a Reply