我有以下正在工作的查询:
$query = "SELECT
a.student_name,
city,
state,
request_date,
lat,
lng,
(3959 * acos(
cos( radians('".mysql_real_escape_string($center_lat)."') )
* cos( radians( lat ) )
* cos( radians( lng ) - radians('".mysql_real_escape_string($center_lng)."') )
+ sin( radians('".mysql_real_escape_string($center_lat)."') )
* sin( radians( lat ) )
)
) AS distance
FROM lesson_requests a
INNER JOIN (
SELECT student_name, MAX(request_date) AS MaxRequestDate
FROM lesson_requests
WHERE (
3959 * acos(
cos( radians('".mysql_real_escape_string($center_lat)."') )
* cos( radians( lat ) )
* cos( radians( lng )
- radians('".mysql_real_escape_string($center_lng)."') )
+ sin( radians('".mysql_real_escape_string($center_lat)."') )
* sin( radians( lat ) ) )
) < ".mysql_real_escape_string($radius)."
GROUP BY student_name
) b
ON a.student_name = b.student_name
AND a.request_date = b.MaxRequestDate
HAVING distance < ".mysql_real_escape_string($radius)."
ORDER BY distance
LIMIT 0 , 10";
我想要做的是将另一个表加入到名为“供应商”的查询中。该表有一个名为“user_purchased”的值,作为完整查询末尾的过滤器之一,我必须确保名为“vendor”的表中的“user_purchased”不包含“abc_company”字样。像这样使用 MATCH
...AND NOT MATCH(user_purchased) AGAINST ('abc_company')
有人可以帮我加入这个附加表吗?
提前致谢!