jimjack145 Posted April 24, 2007 Share Posted April 24, 2007 "SELECT candidate.first_name, candidate.last_name, user.first_name, user.last_name, client.city, candidate_joborder_status.short_description, client.name FROM user INNER JOIN (( client INNER JOIN (( candidate INNER JOIN candidate_joborder ON candidate.candidate_id = candidate_joborder.candidate_id ) INNER JOIN joborder ON candidate_joborder.candidate_joborder_id = joborder.joborder_id ) ON client.client_id = joborder.client_id ) INNER JOIN candidate_joborder_status ON candidate_joborder.status = candidate_joborder_status.candidate_joborder_status_id) ON user.user_id = candidate.entered_by WHERE ( ( ( user.user_id ) = 1257 ) ) LIMIT 0, 30 ; "; Above mentioned is my query used INNER Join with six tables. This query run at phpmyadmin perfectly but when i try to run this into php and get data into html format then give an error. Please check query if there is any wrong in code. Regards JIMI Quote Link to comment https://forums.phpfreaks.com/topic/48411-inner-join-of-six-tables-query-not-running-from-php-form/ Share on other sites More sharing options...
bubblegum.anarchy Posted April 24, 2007 Share Posted April 24, 2007 I have always been under the impression that semi-colons were not allowed at the end of a query inside a string but another member here seemed adamant that the addition of a semi-colon was not erroneous. Quote Link to comment https://forums.phpfreaks.com/topic/48411-inner-join-of-six-tables-query-not-running-from-php-form/#findComment-236743 Share on other sites More sharing options...
btherl Posted April 24, 2007 Share Posted April 24, 2007 What error do you get? Quote Link to comment https://forums.phpfreaks.com/topic/48411-inner-join-of-six-tables-query-not-running-from-php-form/#findComment-236745 Share on other sites More sharing options...
jimjack145 Posted April 24, 2007 Author Share Posted April 24, 2007 I am getting error as below: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL Also getting query which i am not using for data. ""SELECT candidate . first_name , candidate . last_name , user . first_name , user . last_name , client . city , candidate_joborder_status . short_description , client . name ' . ' FROM user INNER JOIN ( ( client INNER JOIN ( ( candidate INNER JOIN candidate_joborder ON candidate . candidate_id = candidate_joborder . candidate_id ) INNER JOIN joborder ON candidate_joborder . candidate_joborder_id = joborder . joborder_id ) ON client . client_id = joborder . client_id ) INNER JOIN candidate_joborder_status ON candidate_joborder . status = candidate_joborder_status . candidate_joborder_status_id ) ON user . user_id = candidate . entered_by ' . ' WHERE ( ( ( user . user_id ) = '" .$_POST['from']. "' ) ) LIMIT 0, 30 ; ";" Not getting what problem with my code. Hope solve as soon as possible. Please need you people help to solve this issue. JIMI Quote Link to comment https://forums.phpfreaks.com/topic/48411-inner-join-of-six-tables-query-not-running-from-php-form/#findComment-236750 Share on other sites More sharing options...
bubblegum.anarchy Posted April 24, 2007 Share Posted April 24, 2007 Post the entire code block. You should have something like: $query = "SELECT column FROM table WHERE condition IS TRUE LIMIT 1"; $result = mysql_query($query); $record = mysql_fetch_array($result); Placing the query string where the result identifier variable is supposed to be would produce an error similar to what you have discribed. Quote Link to comment https://forums.phpfreaks.com/topic/48411-inner-join-of-six-tables-query-not-running-from-php-form/#findComment-236803 Share on other sites More sharing options...
Barand Posted April 24, 2007 Share Posted April 24, 2007 The ";" won't give an error, but it isn't necessary unless - running query from mysql command line - it's a query inside a sql script with mulyiple queries Always check mysql_error when you use mysql_query. Try rearranging it, <?php $query = "SELECT candidate.first_name, candidate.last_name, user.first_name, user.last_name, client.city, candidate_joborder_status.short_description, client.name FROM user INNER JOIN candidate ON user.user_id = candidate.entered_by INNER JOIN candidate_joborder ON candidate.candidate_id = candidate_joborder.candidate_id INNER JOIN joborder ON candidate_joborder.candidate_joborder_id = joborder.joborder_id INNER JOIN client ON client.client_id = joborder.client_id INNER JOIN candidate_joborder_status ON candidate_joborder.status = candidate_joborder_status.candidate_joborder_status_id WHERE user.user_id = 1257 LIMIT 0, 30"; $res = mysql_query($query) or die (mysql_error()); ?> Personally, I think it's more legible if aliases are used, eg <?php $query = "SELECT c.first_name, c.last_name, u.first_name, u.last_name, cl.city, js.short_description, cl.name FROM user u INNER JOIN candidate c ON u.user_id = c.entered_by INNER JOIN candidate_joborder cj ON c.candidate_id = cj.candidate_id INNER JOIN joborder j ON cj.candidate_joborder_id = j.joborder_id INNER JOIN client cl ON cl.client_id = j.client_id INNER JOIN candidate_joborder_status js ON cj.status = js.candidate_joborder_status_id WHERE u.user_id = 1257 LIMIT 0, 30"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/48411-inner-join-of-six-tables-query-not-running-from-php-form/#findComment-237391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.