一個(gè)MySql查詢(xún)問(wèn)題
問(wèn)題描述
數(shù)據(jù)如下:
idcol1a,b,d 2a,b,c
我的查詢(xún)條件:
col=(a,b) 要求查到id為1,2的兩行
col=(a,d) 查到id為1的行
col=(a,c) 查到id為2的行
col=(a) 查到id為1,2的兩行
請(qǐng)教下大家有沒(méi)有什么方法呢?
問(wèn)題解答
回答1:以第一個(gè)為例。
select * from tablename where find_in_set(’a’, col)>0 and find_in_set(’b’, col)>0;回答2:
1.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col) and find_in_set(’b’,col)
2.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col) and find_in_set(’d’,col)
3.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col) and find_in_set(’c’,col)
4.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col)
相關(guān)文章:
1. golang - 用IDE看docker源碼時(shí)的小問(wèn)題2. javascript - 請(qǐng)指條明路,angular的$event,在select中卻是undefined?3. 前端 - @media query 使用出現(xiàn)的問(wèn)題?4. 我何時(shí)應(yīng)該在Java中使用JFrame.add(component)和JFrame.getContentPane()。add(component)5. html - css氣泡,實(shí)現(xiàn)“倒三角(不知道算不算三角了)”可透明的。6. 運(yùn)行python程序時(shí)出現(xiàn)“應(yīng)用程序發(fā)生異?!钡膬?nèi)存錯(cuò)誤?7. docker - 如何修改運(yùn)行中容器的配置8. 利用IPMI遠(yuǎn)程安裝centos報(bào)錯(cuò)!9. phpstudy8.1沒(méi)集成mysql-front10. html5和Flash對(duì)抗是什么情況?

網(wǎng)公網(wǎng)安備