TP5 查詢 字符串條件如何實現
當查詢條件是 (1,3,8)
數據庫字段也是(2,3,4)
這種情況改如何查詢呢?
主要用到FIND_IN_SET
$where[ ]=>['exp',Db::raw("FIND_IN_SET(2, industry)")]]
$industry = Db::table('admin')->where(['id'=>$uid])->value('industry');
$industry =explode(',',$industry );
foreach($industry as $k=>$v){
$where2 .= ($where2?' or ':'')." FIND_IN_SET('$v',industry)";
}
Where 條件進行拼接 就行啦
文章來源:劉俊濤的博客 歡迎關注公眾號、留言、評論,一起學習。
__________________________________________________________________________________
若有幫助到您,歡迎捐贈支持,您的支持是對我堅持最好的肯定(*^_^*)