zgfp.net
当前位置:首页 >> 查A表中A字段 likE B表中B字段的所有记录,怎么写sql >>

查A表中A字段 likE B表中B字段的所有记录,怎么写sql

若A里的a字段要等于B中的b字段就用1L的写法,若是包含就这么写 select * from A where exists (select 1 from B where A.a like '%'+B.b+'%')

Sql Server 如下: 一: select * from a where exists (select 1 from b where code='S' and b.value+',' like '%'+a.it+',%' ) 二: select * from a where (select count(1) from b where code='S' and b.value+',' like '%'+a.it+',%' ) >0

select * from a,b where a.姓名=b.姓名 你后面条件用到了b.姓名,但是在前面没有声明

select * from A where exists(select 1 from B where charindex(B.b ,A.a) > 0) --oracle select * from A where exists(select 1 from B where instr(A.a,B.b,1,1) > 0)

SELECT A.户名FROM TABLE_A A, TABLE_B BWHERE A.户名 = B.户名(+)WHERE B.户名 IS NULL 还可以有其他方法:1 select distinct A.ID from A where A.ID not in (select ID from B) 1 select A.ID from A left join B on A.ID=B.ID where B.ID is...

EXISTS写法: SELECT A.条码 FROM TABLE1 A WHERE EXISTS(SELECT 1 FROM TABLE2 B WHERE A.条码 = B.ITEM_NO) ; INNER JOIN写法: SELECT A.*,B.* FROM TABLE1 A INNER JOIN TABLE2 B ON A.条码 = B.ITEM_NO ; 还有其他的写法....小表关联可以用I...

左连Left Join 表B中存了表A要的信息,相连字段假设是AID,即B表中有个字段AID,是与A表中ID相关联的 SELECT A.*, B.你要的字段 FROM A LEFT JOIN B ON A.ID = B.AID

如果 B中jsx 只要在表A中的dyxt 和hcxt 有相等的,不一定A中的一行。jsx=dyxt=hcxt select b.id,b.jsx from b where b.jsx in(select dyxt from a) and b.jsx in (select hcxt from a) 如果要是一行 select b.id,a.dyxt,a.hcxt from a inner joi...

select * from tablename where B in (select A from tablename)

select a,b,c,count(*) as 重复记录 from 表 group by a,b,c

网站首页 | 网站地图
All rights reserved Powered by www.zgfp.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com