Mysql 查询从一个 table 到另一个的列表字段值

Mysql query for listing field values from one table to another

我有以下 mysql 查询:

  SELECT order_id, CONCAT(firstname, ' ', lastname) AS customer, shipping_code, total, currency_code, currency_value, date_added, date_modified FROM oc_order` o LEFT JOIN (select komercijalista from oc_customer (order.customer_id = customer.customer_id))

我正在尝试列出 oc_order table 中 komercijalista 字段(属于 oc_customer table)的值。我正在尝试通过 customer_id 连接它们,两者都有,但我在左连接时失败了。有什么建议吗?除了更好地学习 mysql 之外,我已经在努力做到这一点,这就是我需要你帮助的地方。谢谢

SELECT o.order_id, CONCAT(o.firstname, ' ', o.lastname) AS customer, o.shipping_code, o.total, o.currency_code, o.currency_value, o.date_added, o.date_modified ,b.komercijalista FROM `oc_order` o left join (select komercijalista from oc_customer) b on o.order_id = b.customer.order_id

试试这个

感谢@p.ganesh,我设法弄清楚了如何编写查询。如果有人需要这个,这里是解决方案:

SELECT order_id, CONCAT(firstname, ' ', lastname) AS customer, shipping_code, total, currency_code, currency_value, date_added, date_modified FROM oc_order` o LEFT JOIN (select komercijalista from oc_customer (order.customer_id = customer.customer_id))