where (id != 5 and age > 20 ) or (id > 15 and age < 18 ) ;
用 $map['_complex'] 例如: $where['name'] = array('like','%thinkphp%'); $where['title'] = array('like','%thinkphp%'); $where['_logic'] = 'or'; $map['_complex'] = $where; $map['id'] = array('gt',1); 查询条件是 ( id > 1) AND ( ( name like '%thinkphp%') OR ( title like '%thinkphp%') )
//另外, in 、FIND_IN_SET('1',user_per) 查询方法 【[注:in前的变量用于数值, FIND_IN_SET后的变量用于字符串】
if($catid){ $catarray[]='1,2'; $map['cat_id']=array('in',$catarray); } if($brand_id){ $map['brand_id']=$brand_id; $where=$map; } if($user_per){ //FIND_IN_SET('1',user_per) $map['_string'] = 'FIND_IN_SET('."'$user_per'".',user_per)'; $where=$map; }
=========================
注意:
select * from treenodes where FIND_IN_SET($id,'1,2,3,4,5');
select * from treenodes where FIND_IN_SET($id,id);
(变量,数据库字段)
使用find_in_set函数一次返回多条记录
id 是一个表的字段 然后每条记录分别是id等于1,2,3,4,5的时候
有点类似in (集合)
select * from treenodes where id in (1,2,3,4,5);
另外,一对多