MySQL查询只返回一行

时间:2015-07-30 19:06:26

标签: php mysql

为什么此查询只返回一行的任何想法?

SELECT c.category_id, c.parent_id, cd.name, cd.description 
FROM mydb_category c 
LEFT JOIN mydb_category_description cd 
ON (c.category_id = cd.category_id) 
WHERE c.category_id IN ('46,59') 
AND c.status        = '1' 
AND cd.language_id  = '1'

language_id是正确的,status是正确的,但由于某种原因,我只返回category_id 46行。

1 个答案:

答案 0 :(得分:0)

删除IN('46,49')中的引号,以便您的查询如下所示:

SELECT 
    c.category_id, c.parent_id, cd.name, cd.description
FROM
    mydb_category c
        LEFT JOIN
    mydb_category_description cd ON (c.category_id = cd.category_id)
WHERE
    c.category_id IN (46,59)
        AND c.status = '1'
        AND cd.language_id = '1'

查看documentation以获取更多信息。祝你好运!