且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP MySQL:小于等于大于的查询

更新时间:2023-02-10 15:59:49

使用MySQl的BETWEEN从不使用引号来比较数字.因此查询变为:

Use the MySQl's BETWEEN and NEVER use quotes for comparing numbers. So the query becomes:

$sql = "SELECT *
  FROM shops
  WHERE shop_id = $shopID
    AND lat BETWEEN $lat_min AND $lat_max
    AND lng BETWEEN $long_min AND $long_max";

在这里,我认为shop_id列是自动递增的数字.

Where, I have considered that shop_id column is auto-incremental number.