今天看代码,看到了这么一句

  $sql_hot_prudct = "SELECT g.*,g.id as goods_id,g.title as goods_name,g.goods_price as shop_price,pubtime as last_update,u.*,r.region_name FROM ".$ecs->table('b2b_supply')." AS g LEFT JOIN  ". $GLOBALS['ecs']->table('users') ." AS u ON u.user_id = g.user_id LEFT JOIN ".$ecs->table('region')." r  ON g.province=r.region_id WHERE 1 and  g.type=1  and g.is_show=1 and b2b_category=".$row['b2b_category']." ORDER BY hits DESC  LIMIT 0,4";

 

看到 where 1 有点觉得不符合规则。百度搜了一下大多是where 1=1

当where 后边的变量都不确定时候。 需要出现where  所以加一个绝对为真的变量 where 1 或者  where 1=1

小技巧,哈哈。 

相关文章:

  • 2022-02-02
  • 2021-10-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-28
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案