I have to create a view in MySQL, this is the code:
CREATE VIEW dashboard_sales AS (
SELECT o.order_id,o.order_date,o.order_status,op.op_status,oi.oi_qty
FROM
order o
LEFT JOIN
order_items oi
ON
o.order_id = oi.order_id
LEFT JOIN
order_payment op
ON
o.order_id = op.order_id
GROUP BY o.order_id
);
but when I execute in phpmyadmin, I get an error:
1064 – 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 ‘order o
LEFT JOIN
order_items oi
ON
o.order_id = oi.’ at line 4
How to solve this problem?
2
Answers
You need a backtick for
order
When you use the keywords for the name of the tables, you should place the table between the Brackets.
);