Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
编写sql查询以从表用户获取所有记录_Sql - Fatal编程技术网

编写sql查询以从表用户获取所有记录

编写sql查询以从表用户获取所有记录,sql,Sql,请编写sql查询以从表用户获取所有记录,这些用户在表测试结果中没有相应的记录: 用户: _____________________ id | name | test_id _____________________ 1 | Hans |10 2 |John |20 如果我答对了你的问题,我将在下面的查询中给出你想要的结果 请试一试,你会得到答案的 select * from users where test_id not in ( select test_id from

请编写sql查询以从表用户获取所有记录,这些用户在表测试结果中没有相应的记录:

用户:

_____________________
id  | name | test_id
_____________________
1   | Hans |10
2   |John  |20
如果我答对了你的问题,我将在下面的查询中给出你想要的结果

请试一试,你会得到答案的
select *
from users 
where test_id not in
(
  select test_id
  from test_results
)
SELECT * FROM `users` WHERE users.test_id NOT IN (SELECT testId FROM test_results)