我正在尝试编写一个MySQL搜索,找到最低imageID
,其他两列= 0.在这种情况下,返回的imageID
将是8.
ImageId Processing Finished
5 0 1
6 1 0
7 0 1
8 0 0
9 1 0
10 0 1
11 1 0
12 0 0
13 0 0
14 0 0
15 0 0
答案 0 :(得分:2)
找到最低的imageID,其他两列= 0
只需在查询中转换您的句子:
(find) (the lowest imageID) (where the other two columns = 0) [SELECT] [MIN(imageID)] [WHERE Processing = 0 AND Finished = 0]
所以你的完整查询应该是(使用MIN()
聚合函数):
SELECT MIN(ImageId) as LowestImageId
FROM Mytable
WHERE Processing = 0
AND Finished = 0
答案 1 :(得分:1)
select min(ImageId) from tablename where processing=0 and finished=0;
这是相当基本的SQL,如果你自己做一些研究,很容易找到。
答案 2 :(得分:0)
SELECT MIN(ImageId) FROM your_table WHERE Processing = 0 AND Finished = 0