您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql 多条件查询有关问题

2024/2/29 5:26:12发布26次查看
mysql 多条件查询问题
select * from subcatalog where name like '%$keywords%' and catalog = $catalog order by rank $rank limit $pages, $rows
上面的语句,怎么可以做到当 $catalog 这个值为空的时候,可以搜索其他的数据,现在这里catalog = $catalog 为空的时候列表就没有东西出来了 
分享到: 更多
------解决方案--------------------
思路这样子的,语法自己调整下:
if($catalog==''){
$tiaojian = '';
}else{
$tiaojian = and catalog = $catalog;
}
$sql = select * from subcatalog where name like '%$keywords%' $tiaojian order by rank $rank limit $pages, $rows

该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product