mysql - SQL,选择不等于的地方

标签 mysql sql

我有两张 table :-

学生表

std_ID|std_Name
------+--------
1     |  Jhon
2     |  Peter
3     |  Mic
4     |  James

学生批处理表

B_std_ID|B_Batch_ID
--------+-------------
1       |  3
2       |  6
3       |  7

我想要那些没有被批量录取的学生, 我想要这个

std_ID|std_Name
------+--------
4     |  James

我尝试了这段代码

SELECT std_ID, std_Name FROM student , studentBatch WHERE std_ID <> B_std_ID;

但是没有成功,请帮我解决

最佳答案

select std_id
from student
where std_id not in (select B_std_ID from studentbatch)

关于mysql - SQL,选择不等于的地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24368191/

相关文章:

php - 尝试使用 eloquent 从 SQL 数据库获取最大数量时出错

PHP MYSQL 查询使用 Ajax 数据返回 null,但不返回硬编码数据

mysql - 滚动 12 个月的数据 Sum 运算

php - 无限滚动系统,需要更改获取最后一项的方法

sql - Nvarchar 列值加倍,如何检测并修复此问题?

python - MySQL 表创建模板 - Python

sql - 关于dsn字符串的查询

mysql - 将我的原始 sql 转换为 Eloquent 代码时出错

mysql - 自今年特定月份以来在 SQL 中添加的记录

mysql - Where 子句未按预期工作 : I get data from 2 different IDs when only one is specified