Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 查询未正确筛选结果_Php_Mysql - Fatal编程技术网

Php 查询未正确筛选结果

Php 查询未正确筛选结果,php,mysql,Php,Mysql,这是我的疑问: $sql = "SELECT * , (3956 * 2 * ASIN(SQRT( POWER(SIN(('$lat' - lat) * pi()/180 / 2), 2) +COS('$lat' * pi()/180) * COS(lat * pi()/180) * POWER(SIN(('$lon' - lon) * pi()/180 / 2), 2) ))) as distance from posts WHERE posts.subname LIKE '%$subje

这是我的疑问:

$sql = "SELECT * , (3956 * 2 * ASIN(SQRT( POWER(SIN(('$lat' - lat) *  pi()/180 / 2), 2) +COS('$lat' * pi()/180) * COS(lat * pi()/180) * POWER(SIN(('$lon' - lon) * pi()/180 / 2), 2) ))) as distance  from posts WHERE posts.subname LIKE '%$subject%' AND posts.pricing <= '$rate' ".$add_here." GROUP BY posts.UUID having  distance <= '$distance' order by distance";
在浏览器中

SELECT * , 
(3956 * 2 * ASIN(SQRT( POWER(SIN(('2.993518' - lat) * pi()/180 / 2), 2) + 
COS('2.993518' * pi()/180) * COS(lat * pi()/180)
 * POWER(SIN(('101.7874058' - lon) * pi()/180 / 2), 2) ))) 
    as distance
from posts 
WHERE posts.subname LIKE '%tamil%' 
AND posts.pricing <= '161' 
AND posts.morning IN ('sun') 
OR posts.afternoon IN ('sun') OR posts.evening IN ('sun','mon') 
GROUP BY posts.UUID 
having distance <= '40' 
order by distance

我遇到的问题是,此查询的结果不会筛选子名称。它只是过滤和帖子。定价问题在于你的WHERE子句

WHERE posts.subname LIKE '%tamil%' 
AND posts.pricing <= '161' 
AND posts.morning IN ('sun') 
OR posts.afternoon IN ('sun') OR posts.evening IN ('sun','mon') 
如果我理解你的意思,你是想说选择: “%tamil%”和定价
WHERE posts.subname LIKE '%tamil%' 
AND posts.pricing <= '161' 
AND (posts.morning IN ('sun') 
    OR posts.afternoon IN ('sun') 
    OR posts.evening IN ('sun','mon'))