Jump to content

need help joining in a second table


rmelino

Recommended Posts

I am building on a query that someone from this forum helped me with shown at the end of this thread:

 

http://www.phpfreaks.com/forums/index.php/topic,266134.0.html

 

What i am trying to do is join in another table to the query called 'vendor'.  That table has a value called 'user_purchased' and as one of the filters at the end of the complete query I have to make sure that 'user_purchased' from the table named 'vendor' does not contain the words 'abc_company'.  using MATCH like this

 

...AND NOT MATCH(user_purchased) AGAINST ('abc_company')

 

Could someone help me with the join of this additional table?

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/264138-need-help-joining-in-a-second-table/
Share on other sites

Sorry, the working one is in the original thread.  Here it is again...

 

$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";

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.