-1

私はこのSQLクエリを持っています

SELECT sites.id, sites.url, GROUP_CONCAT(categories.name,"|",
    categories.color SEPARATOR ",") AS categories
FROM sites
LEFT JOIN categories_data ON sites.id = categories_data.sites_id
LEFT JOIN categories ON categories_data.categories_id = categories.id
WHERE sites.deleted=0 
AND WHERE categories.deleted=0 
AND WHERE categories_data.deleted=0 
GROUP BY sites.id

次のエラーが表示されます。

Database_Exception [ 1064 ]: 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 'WHERE categories.deleted=0 AND WHERE 
categories_data.deleted=0 GROUP BY sites.id' at line 5 [ SELECT sites.id, 
sites.url, GROUP_CONCAT(categories.name,"|",categories.color SEPARATOR ",") 
AS categories FROM sites LEFT JOIN categories_data ON sites.id = 
categories_data.sites_id LEFT JOIN categories ON 
categories_data.categories_id = categories.id WHERE sites.deleted=0 
AND WHERE categories.deleted=0 AND WHERE categories_data.deleted=0 GROUP BY 
sites.id ]

このエラーはどういう意味ですか?

4

1 に答える 1

6

3つのWHERE節があるからです。複数の条件がある場合は、条件演算子を使用してそれらを区切る必要があります。

SELECT ...
FROM   ... JOIN ...
WHERE  sites.deleted = 0 AND 
       categories.deleted = 0 AND 
       categories_data.deleted = 0 
GROUP  BY sites.id
于 2013-04-17T15:41:41.400 に答える