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

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.