0

このクエリをマージする必要があります

SELECT 
*,
(SELECT 
        CONCAT(c.firstname, ' ', c.lastname)
    FROM
        wwwpser_customer c
    WHERE
        c.customer_id = o.customer_id) AS customer
FROM
wwwpser_order o
WHERE
o.order_id = '20'

SELECT 
orders . *, wwwpser_comuna.provincia_id AS payment_provincia_id
FROM
wwwpser_order orders
    LEFT JOIN
wwwpser_comuna ON (orders.payment_city = wwwpser_comuna.comuna_id) 

SQL構文は私にとって新しいので、これについて少し助けが必要です、thx

4

2 に答える 2

1
SELECT CONCAT(c.firstname, ' ', c.lastname)
,      wc.provincia_id 
,      o.*
FROM   wwwpser_order o
LEFT JOIN   
       wwwpser_customer c
ON     c.customer_id = o.customer_id
LEFT JOIN
       wwwpser_comuna wc
ON     wc.comuna_id = o.payment_city
WHERE  o.order_id = 20
于 2012-12-22T16:05:03.300 に答える
0

これがあなたの解決策になるはずです。

SELECT 
o.*,                                                -- modified (qualified the
(SELECT                                             -- asterisk)
        CONCAT(c.firstname, ' ', c.lastname)
    FROM
        wwwpser_customer c
    WHERE
        c.customer_id = o.customer_id) AS customer, 
c.provincia_id AS payment_provincia_id              -- added from second query
FROM
wwwpser_order o
    LEFT JOIN                                       -- added from second query
wwwpser_comuna c ON (o.payment_city = c.comuna_id)  -- added from second query
WHERE
o.order_id = '20'

ただし、一般的なSQL構文について学ぶことを強くお勧めします。MySQLチュートリアルにはいくつかの便利な例があります

于 2012-12-22T16:32:52.403 に答える