表A
no name
1 lu,li,zhang
2 zhou,wei,liu
3 li,fang
表B
no name sex
1 li 1
2 lu 0
3 zhou 0
4 zhang 1
怎么实现
复制代码 代码如下:
select * from A where A.name like (select B.name from B where B.sex=1)
----------------------------------------------------------------------------------------------------------------------------
sqlserver写法
复制代码 代码如下:
select distinct a.no,a.name from a,b where charindex(b.name,a.name)>0 and b.sex=1
oracle写法
复制代码 代码如下:
select distinct a.no,a.name from a,b where instr(a.name,b.name)>0 and b.sex=1
----- instr() 定位子串 instr('Hello World', 'or') 返回8
最后
以上就是贪玩皮带最近收集整理的关于sql语句like多个条件的写法实例的全部内容,更多相关sql语句like多个条件内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复