I have a fairly simple MySQL query:
(SELECT
id
, creation_date AS date
, 'order' AS type
FROM bus_orders
WHERE 1
UNION ALL SELECT
id
, start_date AS date
, 'contract start' AS type
FROM bus_contracts
WHERE 1
UNION ALL SELECT
id
, end_date AS date
, 'contract end' AS type
FROM bus_contracts
WHERE 1
) ORDER BY date DESC LIMIT 5
Running it however is giving me the syntax error:
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 ‘UNION ALL SELECT id, start_date AS date, ‘contract start’ AS
type FROM bus_contr’ at line 1
I’m sure it is something obvious, but I can’t quite figure it out. Can anyone spot what I’m doing wrong here?
remove
WHERE 1or change it toWHERE 1=1