I run the following code in the mariadb terminal and it works fine. As soon as i put it into a .sql file and run it, I get the error shown below. The database is set up correctly, with the schema working fine. I'm trying to get an output like this like this:
+----------+
| ALCOHOL_FREE_COMPLIANT |
+----------+
| 0 |
+----------+
SELECT NOT EXISTS (
select market_postcode, truck_id, alcohol from (
SELECT * FROM buybeverage JOIN beverage
)AS beverageOrders
LEFT JOIN ChippOrder ON (chipporder.order_id = beverageOrders.order_id)
WHERE alcohol = 1 AND market_postcode = "E16AA"
) AS ALCOHOL_FREE_COMPLIANT;
ERROR 1064 (42000) at line 43: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT NOT EXISTS ( select market_postcode, truck_id, alcohol from ( ' at line 20