我想使用如下查询从我的数据库中选择一行:Select * FROM List WHERE personStat='waiting' AND depId='Admin' AND min(categoryTime);
。
我可以使用3个过滤器:Waiting,Admin和最小categoryTime。
如何编写查询?
ID | personStat | depId | CategotyTime
--------------------------------------------------------
2 | waintig | Admin | 10
5 | waiting | Admin | 5 This will be the answer!!!
7 | atending | Conse | 30
10 | atending | Eco | 20
55 | complete | Eco | 10
答案 0 :(得分:0)
AND min(categoryTime)
Select * FROM List WHERE personStat='waiting' AND depId='Admin' AND 'CategotyTime' >10;
也许是这样?
答案 1 :(得分:0)
为什么不使用
Select * FROM List WHERE personStat='waiting' AND depId='Admin' ORDER BY categoryTime ASC LIMIT 1
也许你已经尝试过:
Select * FROM List WHERE personStat='waiting' AND depId='Admin' AND categoryTime=min(categoryTime);
但是在min(categoryTime)为5的情况下这不起作用,但过滤器的最低categoryTime是10(例如)
答案 2 :(得分:0)
使用按排序&限制:
SELECT * FROM List WHERE personStat='waiting' AND depId='Admin' ORDER BY CategotyTime ASC LIMIT 1;