在编写查询时面临困难

时间:2014-09-26 12:37:57

标签: sql sqlite

我正在尝试编写查询,其中表的名称enter_mode表的出勤值不等于check_in,这意味着他当天没有签到,或者当相同列名值的记录计数等于check_out大于1表示他已经签出。 使用sqlite

below is my query

SELECT * FROM Attendance 
WHERE emp_id="+emp_id+" 
   and cdate='"+cdate+"' 
   and enter_mode!='check_in' 
UNION 
SELECT * FROM Attendance 
WHERE emp_id="+emp_id+" 
   and cdate='"+cdate+"' 
   and enter_mode!='check_out'

请帮我解决这个问题。谢谢提前

1 个答案:

答案 0 :(得分:0)

第二部分尝试这个:

SELECT * FROM Attendance 
WHERE emp_id="+emp_id+" 
   and cdate='"+cdate+"' 
   and enter_mode='check_out'
GROUP BY emp_id
HAVING COUNT(emp_id) > 1

顺便说一下,您应该始终粘贴表格定义。

相关问题