我有一个表 project_info ,我想检查特定项目(例如project_id = 1 )是否具有状态 0 ,至少有一个start_date是< =今天的日期。
project_info
if(above logic is true){
//do somthing
}
else{
do nothing
}
我如何在mysql中执行此操作?
SELECT DISTINCT project_id from project_info where
status field (contain all 0
with no 1,loop through the whole table for project_id =1)
and start_date(at least one start_date <=curdate)
答案 0 :(得分:1)
我认为这些SQL对你有用。
select * from project_info where project_id >=1 and status =0 and
start_date <= CURDATE()
谢谢。