Mysql join 2 database and 3 tables query?
SELECT db1_t1.userid as userid
, db1_t1.customer_id as vw_customer
, db2_t1.customers_id as customer
, db2_t1.orders_id as order
FROM database1.table1 db1_t1
LEFT JOIN database2.table1 db2_t1
ON db1_t开发者_如何学编程1.customer_id = db2_t1.customers_id
It gives me this 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 'order FROM database1.table1 db1_t1 LEFT JOIN database2.' at line 2
I am using php and mysql.
order
is a keyword - think ORDER BY my_column
.
I'd suggest renaming it, but you could enclose it in backticks
db2_t1.orders_id AS `order`
精彩评论