rmelino Posted June 13, 2012 Share Posted June 13, 2012 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 More sharing options...
fenway Posted June 16, 2012 Share Posted June 16, 2012 First, start by posting the working query. Link to comment https://forums.phpfreaks.com/topic/264138-need-help-joining-in-a-second-table/#findComment-1354468 Share on other sites More sharing options...
rmelino Posted June 17, 2012 Author Share Posted June 17, 2012 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 https://forums.phpfreaks.com/topic/264138-need-help-joining-in-a-second-table/#findComment-1354530 Share on other sites More sharing options...
fenway Posted June 30, 2012 Share Posted June 30, 2012 What have you tried so far? Link to comment https://forums.phpfreaks.com/topic/264138-need-help-joining-in-a-second-table/#findComment-1358151 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.