我认为这段代码可以进行一些修改,但我不确定如何引用表名和列名,或者如何比较值。获取在另一个表中没有值的行
SELECT a.id
FROM a LEFT JOIN b ON a.id = b.a_id
WHERE b.id IS NULL;
我有两个表,组和用户。组是这个样子的所有可用组的列表:
| group | mission |
| test | just testing |
| design | still testing |
| rand | last one |
用户是用户的列表:
| user | group |
| me | test |
| me | rand |
| you | test |
| you | design |
只有一个用户在同一时间进行查询。
| group |
| design |
所以我想它会是这样的:如果查询是用户的“我”运行,它应该只是返回
select group from groups where username = "me" and ....
而这也正是我迷路。
'其中b.id为空和a.user ='me''? –
Google,了解'SQL JOINS' –