假如,user表有一字段 pids,pids字段是用#(实际用逗号合适)隔开的师傅id。现在查询师傅id:168的徒弟有哪些(徒弟、徒孙、徒孙的徒弟、徒孙的徒孙。。。。)
sql: select * from user where concat('#',pids,'#') like '%#168#%';
select * from user where concat('#',pids,'#') regexp '#168#';
select * from user where concat('#',pids,'#') regexp concat('#',168,'#');
注意:concat(',',pids,',') regexp concat(',(',replace('{$uid}',',','|'),'),')
http://www.jcodecraeer.com/a/phpjiaocheng/2012/0605/228.html