一个条件查询的问题..
表:userinfo
user_id,user_name
表:wages
user_id,month (month是月份字段格式(2007-8))
要求:找出user_id
条件:满足month是当前月,且在wages中无数据记录的user_id
------解决方案--------------------表:userinfo
user_id,user_name
表:wages
user_id,month (month是月份字段格式(2007-8))
要求:找出user_id
条件:满足month是当前月,且在wages中无数据记录的user_id
select user_id from userinfo where user_id not in (select * from wages where month = '2007-08 ')
------解决方案--------------------select user_id from userinfo where user_id not in (select * from wages where month = left(convert(varchar(10),getdate(),120),7))
------解决方案--------------------表:userinfo
user_id,user_name
表:wages
user_id,month (month是月份字段格式(2007-8))
要求:找出user_id
条件:满足month是当前月,且在wages中无数据记录的user_id
------------------
select * from userinfo
where user_id not in(select user_id from wages where datepart(month,cast(month+ '01 'as datetime))=datepart(month,getdate()))