0

mysql db から表示されるデータを取得する必要があります。以下のコードは、私がやろうとしていることを示していると思いますが、実行は間違いなく間違っています。これを機能させるには、何を変更する必要がありますか?

SELECT 
up.model AS style,
up.list_price AS price,
GROUP_CONCAT(t1.name) AS colorlist,
GROUP_CONCAT(t2.name) AS sizelist,
nr.title,
nr.body AS description,
FROM 
uc_products up,
(SELECT c.name FROM uc_attributes a 
       JOIN uc_product_options b ON (b.nid = a.nid) 
       JOIN uc_attribute_options c ON (c.oid = b.oid AND c.aid = 6) 
       WHERE a.nid = up.nid) AS t1,
(SELECT c.name FROM uc_attributes a 
       JOIN uc_product_options b ON (b.nid = a.nid) 
       JOIN uc_attribute_options c ON (c.oid = b.oid AND c.aid = 9) 
       WHERE a.nid = up.nid) AS t2
LEFT JOIN node_revisions nr ON (nr.nid = up.nid)

エラー:

#1064 - SQL 構文にエラーがあります。'FROM uc_products up, (SELECT c.name FROM uc_attributes a JOIN uc_product_options' at line 8) 付近で使用する正しい構文については、MySQL サーバーのバージョンに対応するマニュアルを確認してください

4

2 に答える 2

0

問題は の前のコンマだと思いますFROM。これを試して:

SELECT 
up.model AS style,
up.list_price AS price,
GROUP_CONCAT(t1.name) AS colorlist,
GROUP_CONCAT(t2.name) AS sizelist,
nr.title,
nr.body AS description
FROM 
uc_products up,
(SELECT c.name FROM uc_attributes a JOIN uc_product_options b ON (b.nid = a.nid) JOIN uc_attribute_options c ON (c.oid = b.oid AND c.aid = 6) WHERE a.nid = up.nid) AS t1,
(SELECT c.name FROM uc_attributes a JOIN uc_product_options b ON (b.nid = a.nid) JOIN uc_attribute_options c ON (c.oid = b.oid AND c.aid = 9) WHERE a.nid = up.nid) AS t2
LEFT JOIN node_revisions nr ON (nr.nid = up.nid)
于 2013-08-06T20:15:40.207 に答える