LIKE 操作符用于在 WHERE 子句中搜索列中的指定模式。
SELECT * FROM calendar_events WHERE userIds LIKE ‘%,5,%‘ OR userIds LIKE ‘5,%‘ OR userIds LIKE ‘5‘
Thinkphp中,
$infoWhere[‘userIds‘] = array(‘like‘,array(‘%,‘.$cur_id,‘%,‘.$cur_id.‘,%‘,$cur_id.‘,%‘,$cur_id),‘OR‘); $events = M(‘calendar_events‘); $list = $events ->where( $infoWhere) ->field(‘id,text,start_date,end_date,details,subject,userIds‘) ->order(‘start_date ‘) ->select();
原文:http://www.cnblogs.com/JasonTech0713/p/6971377.html