为什么这个查询不起作用?结合有和哪里

时间:2012-09-22 04:03:12

标签: mysql phpmyadmin

SELECT fileUser FROM `images` 
HAVING min(imageid) AND 
WHERE (finished=0 and processing=0)

获得fileUser索引的情况似乎很简单,imageID索引最少{{1}}已完成,处理也= 0.但是,我似乎无法提出一个有效的查询?任何帮助都会很棒。

3 个答案:

答案 0 :(得分:2)

如果您的问题与您的previous question有关,那么您可以尝试以下问题:

SELECT fileUser FROM `images`
WHERE imageid = (SELECT min(imageid) 
                 FROM `images` 
                WHERE finished=0 
                  AND processing=0)

请参阅this SQLFiddle Demo

答案 1 :(得分:1)

另一种方式是

SELECT fileUser 
FROM `images` 
WHERE finished=0 
AND processing=0
ORDER BY imageid
LIMIT 1

答案 2 :(得分:0)

我认为他实际上想要这个

SELECT fileUser FROM `images`
WHERE imageid = (SELECT min(imageid) FROM `images` WHERE (finished=0 and processing=0))