1. 查找pnum字段中包含3或者9的记录
SELECT * FROM test WHERE find_in_set('3',pnum) OR find_in_set('9',pnum);
SELECT * FROM test WHERE CONCAT(',',pnum,',') REGEXP '[^0-9]+[3|9][^0-9]+';
2. cover字段为:(admin/LUpiEMD1Pk6U6B,admin/LUpiEMD1Pk6U6B,admin/LUpiEMD1Pk6U6B)
取逗号分隔第一个词:
select left(cover, LOCATE(',',cover)-1) from product_album
3. MySQL 查询某字段的多条结果显示成按逗号隔开
有表:tel
字段:
id tel
1 13578945620
2 13578945621
3 13578945622
4 13578945623
5 13578945624
查询tel字段,出现的结果是这样的:13578945620,13578945621,13578945622,13578945623,13578945624
select group_concat(tel) from tt
4. 字段Faccounts是逗号隔开的
select Fid,Fname, Ftype, Faccounts from t_organization where concat(',', Faccounts, ',') LIKE concat('%,', ?, ',%') ;