thinkphp一条WHERE查询的写法
where[id]=array(*neq*,5);where[*age*]=array(*egt*,20);这个变成SQL就是whereid!=5andage>=20;但...
where [id] = array(*neq*,5); where[*age*] = array(*egt*, 20);
这个变成SQL就是 where id != 5 and age >= 20;
但我现在要更复杂的SQL语句: where (id != 5 and age > 20 ) or (id > 15 and age < 18 ) ;THINKPHP 应该怎写? 展开
这个变成SQL就是 where id != 5 and age >= 20;
但我现在要更复杂的SQL语句: where (id != 5 and age > 20 ) or (id > 15 and age < 18 ) ;THINKPHP 应该怎写? 展开
2个回答
展开全部
用 $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%') )
例如:
$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%') )
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询