社区
疑难问题
帖子详情
在表A中查找表B中不存在的记录!!(如字段name)
dgnApo
2003-12-01 10:07:13
该怎么写sql语句?
name是主键
...全文
86
6
打赏
收藏
在表A中查找表B中不存在的记录!!(如字段name)
该怎么写sql语句? name是主键
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
6 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
dgnApo
2003-12-01
打赏
举报
回复
我要实现和in的概念相反的功能的sql语句,该怎么写?
pengdali
2003-12-01
打赏
举报
回复
光用:
select * from a where [name] not in (select [name] from b )
如果b表的name有null值是会错的。
pengdali
2003-12-01
打赏
举报
回复
select * from a where name not in (select name from b where name is not null)
sunsunup
2003-12-01
打赏
举报
回复
select * from a where [name] not in (select [name] from b )
sunshareforever
2003-12-01
打赏
举报
回复
select * from a where a.name not in (select name from b )
victorycyz
2003-12-01
打赏
举报
回复
select * from A left join B on A.name=B.name where B.name is null
查询A
表
在B
表
中
不存在
的
记录
查询A
表
在B
表
中
不存在
的
记录
,即把A、B
表
共同的部分去掉再取A
表
剩下的部分; 可以通过指定的
字段
作为条件,并不是需要A/B
表
字段
完全一样才能查询,如下例子: select a.name,a.password,a.dpt from table_a a where a.dpt=‘开发部’ and not exists (select 1 from table_b where b.name = a.n...
SQL
中
采用正则
表
达式
查找
f_name
字段
中
不包含‘a‘、‘b‘、‘c‘的
记录
MySQL
查找
f_name
字段
中
不包含’a’、‘b’、'c’的
记录
要求采用正则
表
达式的时候如果我们采用以下方法: select * from fruits where f_name regexp '[^abc]'; 可见,该命令得到的结果并不符合我们的要求。 想要通过正则
表
达式
查找
f_name
字段
中
不包含’a’、‘b’、'c’的
记录
,有两种方法: 方法一: select * from fruits where f_name not regexp '[abc]'; 方法二 select * fr
SQLserver:查询某个
字段
出现在数据库
中
的哪些
表
中
应用场景 数据库
中
表
太多,需要
查找
字段
在哪些
表
中
出现。 SQL语句 根据自己需要
查找
的
字段
,将SQL语句
中
的column_name替换为需要
查找
的
字段
名,其它无需更改直接复制到数据库进行查询即可。 select a.name
表
名,b.name 列名 from sys.objects a,sys.columns b where object_name(b.object_id)=a.name and b.name='column_name' --column_name 为列名 =============
复制A
表
指定
字段
的内容到B
表
的几种情况
A
表
字段
:id(自动递增),name,pwd,noteB
表
字段
:id(自动递增),name,pwd,note(1)将A
表
id为1的
记录
的name,pwd,note
字段
内容插入B
表
的name,pwd,note
字段
:INSERT INTO `B`(`name`,`pwd`,`note`) (SELECT `name`,`pwd`,`note` FROM `A` WHERE `id`='1')(2)将A
表
的id为1的
记录
复制,还插入A
表
:INSERT INTO `A`(`name`,`pwd`,`note`) (
SQL 查询a
表
中
有但是b
表
中
没有的数据
SQL 查询a
表
中
有但是b
表
中
没有的数据
疑难问题
22,298
社区成员
121,733
社区内容
发帖
与我相关
我的任务
疑难问题
MS-SQL Server 疑难问题
复制链接
扫一扫
分享
社区描述
MS-SQL Server 疑难问题
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章