我有這個鏈接兩個表的MySQL查詢。我想加入主題,從哪裏得到不存在的數據從另一個表。我想從兩個表中得到不存在的數據
這個在這裏得到註冊日期爲用戶
SELECT
t2.name ,phone
FROM
(SELECT name,tid,date_d,class_time AS 'absent'
FROM absent where date_d = '2016-12-04') t1
JOIN
(SELECT name, id,phone AS 'phone'
FROM users ) t2
ON t1.tid = t2.id
group by id
我想誰沒有在表t1從表中的兩 註冊用戶我用同樣的上述查詢,但像這樣的東西ON t1.tid != t2.id
它僅適用於不重複的日期
SELECT
t2.name ,phone
FROM
(SELECT name,tid,date_d,class_time AS 'absent'
FROM absent where date_d = '2016-12-04') t1
JOIN
(SELECT name, id,phone AS 'phone'
FROM users ) t2
ON t1.tid != t2.id
group by id
所以你想誰是不存在的缺席用戶?奇怪.... :) – barudo