查询两张表中不相同的数据
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 SELECT 2 c.userId, 3 c.userName 4 FROM 5 (SELECT 6 * 7 FROM 8 a 9 UNION 10 SELECT 11 * 12 FROM 13 b) c 14 WHERE c.userId NOT IN 15 (SELECT 16 b.`userId` 17 FROM 18 a 19 JOIN b 20 ON a.`userId` = b.`userId`) ;
1 SELECT 2 c.userId, 3 c.userName 4 FROM 5 (SELECT 6 * 7 FROM 8 a 9 UNION 10 SELECT 11 * 12 FROM 13 b) c 14 WHERE c.userId NOT IN 15 (SELECT 16 b.`userId` 17 FROM 18 a 19 JOIN b 20 ON a.`userId` = b.`userId`) ;