我有两个数据表一个是:
“卡片”表包含:
id Department
0000022288 COR
0000043880 NA
0000031643 NA
0000013870 TRAN
0000053900 COR
0000055452 IOR
0000010957 IOR
0000025746 BILL
0000061783 BILL
0000000773 NA
我有另一个表(valid_entry):
date emp_id emp_time
20130101 0000002001 101825
20130102 0000002001 085024
20130103 0000002001 085657
20130106 0000002001 095145
20130107 0000002001 090724
20130108 0000002001 091244
我想显示那些不在有效表中的 id。
我的查询:
SELECT emp_valid_date
, emp_valid_name
, emp_valid_time
, emp_valid_dept
, Name
FROM valid_entry
INNER JOIN Cards ON emp_valid_dept = Depart_Code
WHERE emp_valid_date = '$date'
AND emp_valid_time >= 060000
AND emp_valid_time <= 230000
AND emp_valid_dept != 'DRI' OR emp_valid_time = ''
如果我能得到类似的东西就可以了:
date emp_id emp_time card_id_missing
20130101 0000002001 101825
20130102 0000002001
20130103 0000002001 085657
20130106 0000002001 095145
20130107 0000002001 090724
20130108 0000002001 091244
我想要这样的东西