sql語句like多個條件的寫法實例
發(fā)布日期:2021-12-31 15:03 | 文章來源:gibhub
表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
怎么實現(xiàn)
復(fù)制代碼 代碼如下:
select * from A where A.name like (select B.name from B where B.sex=1)
----------------------------------------------------------------------------------------------------------------------------
sqlserver寫法
復(fù)制代碼 代碼如下:
select distinct a.no,a.name from a,b where charindex(b.name,a.name)>0 and b.sex=1
oracle寫法
復(fù)制代碼 代碼如下:
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
版權(quán)聲明:本站文章來源標注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
相關(guān)文章
下一篇: