网站找哪家做较好,数据库怎么做网站,nike网站开发背景及意义,200平米火锅店装修费用在开发中#xff0c;有时我们可能存了一些复杂json格式不知道怎么查。我这里提供给大家参考下#xff1a;
一、先上表数据格式#xff08;location字段的possiton经纬度以逗号分开的#xff09; {title:澳海文澜府,position:11…在开发中有时我们可能存了一些复杂json格式不知道怎么查。我这里提供给大家参考下
一、先上表数据格式location字段的possiton经纬度以逗号分开的 {title:澳海·文澜府,position:112.850437,28.287553} 打印的sql语句如下 SELECT id,title,location FROM g_property WHERE ( status 0 AND delete_time IS NULL AND ( SUBSTRING_INDEX(TRIM(BOTH FROM json_extract(location, $.position)),,,1) 112.071284 and SUBSTRING_INDEX(TRIM(BOTH FROM json_extract(location, $.position)),,,1) 112.871284 ) ) 二、php tp8框架代码如下
1.拼接where条件sql语句
参数 $location input(location,);if($location ! ){$location json_decode($location,true);$location SUBSTRING_INDEX(TRIM(BOTH \\ FROM json_extract(location, $.position)),,,1) . $location[0]. and SUBSTRING_INDEX(TRIM(BOTH \\ FROM json_extract(location, $.position)),,,1) . $location[2]. and SUBSTRING_INDEX(TRIM(BOTH \\ FROM json_extract(location, $.position)),,,-1) . $location[1]. and SUBSTRING_INDEX(TRIM(BOTH \\ FROM json_extract(location, $.position)),,,-1) .$location[3]. ;} 2.查询代码
$res Property::field(id,title,img,p_prices_trend_id,city,area_id,block_id,place,average_price,location,status,is_topped,is_new,block_name)-where($location)-select();
以上代码具体根据你自已的业务来。本人只上传了核心的代码