mysql查询,用于列出从一个表到另一个表的字段值

vmjh9lq9  于 2021-06-24  发布在  Mysql
关注(0)|答案(2)|浏览(376)

我有以下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))

我试图列出 komercijalista 字段(属于 oc_customer 表)中 oc_order table。我试着通过 customer_id 这两个都有,但我在左连接失败。有什么建议吗?除了更好地学习mysql之外,我已经在努力学习mysql了,这也是我需要你帮助的地方。桑克斯。

ogsagwnx

ogsagwnx1#

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

试试这个

guicsvcw

guicsvcw2#

thanx to@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))

相关问题