66问答网
所有问题
sql语句 如何判断A表中的a列数据是否在B表中的b列中存在
如题 A表中有a列 假设数据为1,2,3
B表中有b列 假设数据为2,3,4
现在需要判断a列中的数据在b列中存在
举报该问题
推荐答案 2009-06-03
select A.a from A,B where A.a=B.b 最简单的判断。
用IN的话可能出错:select a from A where a IN(select b from B)
用exists如楼上所说~
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://66.wendadaohang.com/zd/vvvUinDn.html
其他回答
第1个回答 推荐于2018-04-21
--存在
select *
from A
where exists(select 1 from B where A.a = B.b)
--不存在
select *
from A
where not exists(select 1 from B where A.a = B.b)
本回答被提问者和网友采纳
第2个回答 2009-06-03
SELECT a from A
WHERE a in (select b from B)
第3个回答 2009-06-03
用in语法
相似回答
...
b表b
1字段
数据
和c
表中
c1字段数据)
中的sql语句怎么
写
答:
select from a where a1 not in (select b1 from b)and a1 not in (select c1 from c)2.select from a where a1 not in (select b1 from b union all select c1 from c)3.select from a left outer join b on b.b1=a.a1 left outer join c on c.c1=a.a1 where b1 is nu...
SQL中如何
查询
A表中的数据
有部分
存在B表中
并显示出来
答:
SQL
中查询
A表中的数据
有部分
存在B表中
并显示出来,可以参考下面几种方法:1、select * from B表 where item_no in (select 条码 from A表)2、select * from A表,B表 where A表.条码=B表.item_no
sql语句
判断表数据是否存在
另一个
表中
答:
1、首先在桌面上,点击“Management Studio”图标。2、其次在窗口中,点击“新建查询”按钮。3、接着在窗口中
,输入判断表数据是否存在另一个表中的SQL语句“select test1.no from test1 where EXISTS(select * from test2 where test1.no=test1.no)”。4、再者在窗口中,点击“执行”按钮。5、...
sql语句
:比较同一
表中的
两列,找出
a列
中有而
b列中
答:
建表 create table t(a int,b int)insert into t values (1,2)insert into t values (2,3)执行 select a,b,case when b in (select a from t) then 1 else null end from t结果
sql语句
:比较同一
表中的
两列,找出a列中有而
b列中
...
在
sql语句中
若
表A
里的一
列数据在表B中存在
则在表B中增加一列并标识...
答:
只能
在B中
先增加一列来表示
是否存在
于
A表中
使用flag来表示 1表示存在 select count(*) num from B where B.* = (select A.* num from A)if(num>0) then flag=1;
...
在B表中
不
存在
的记录,并将该记录插入B表(
sql语句
)
答:
你这个问题的前提是A和B是两个具有完全相同列结构的表。设她们都是只有两列,分别设为列1和列2.下面是
SQL
SERVER的查询语言 insert into B select A.列1,A.列2 from A where not exist select * from B where A.列1=B.列1 and A.列2=B.列2 ...
大家正在搜
sql语句增加一列数据
用sql语句给数据库添加列
怎么用sql语句给表添加一列
sql更新数据库的某一列
sql语句双条件判断
sqlserver添加列语句
sqlserver删除列语句
数据库添加列语句
数据库新增列语句
相关问题
SQL中如何查询A表中的数据有部分存在B表中并显示出来
如何查询表A中的某字段的值在表B中不存在?
sql语句 判断表数据是否存在另一个表中
SQL 如何查询表A,字段a,中是否含有表B,字段b,内的数...
SQL中,如何查询存在一个表而不在另一个表中的数据记录
关于sql查询b表中存在,a表中不存在的数据
请教一sql语句实现从a表中判断是否有b表的数据
sql语句,查询表A,判断表A是否有数据,有则连同查出表C的...