我有一张user_test_access
号桌,里面放着test_id
和user_id
.
user_test_access
表存储有权访问测试的所有用户以及创建测试的用户.
id | test_creator | test_id | user_id |
---|---|---|---|
1 | 0 | 1 | 901 |
2 | 0 | 1 | 903 |
3 | 0 | 2 | 904 |
4 | 0 | 2 | 905 |
5 | 0 | 3 | 906 |
6 | 1 | 3 | 907 |
7 | 0 | 3 | 908 |
我想要一个查询,返回没有创建者的所有test_id
.即test_creator=0.
预期结果:
对于特定的数据集,答案将是test_id
、1和2.
不包括test_id 3的原因是因为user_id
907是它的test_creator
.
我试过的是:
SELECT test_id from user_test_access WHERE id = ALL(SELECT id from user_test_access WHERE test_creator=0)
你能帮我找出我做错了什么吗?