0

I have 6 tables in the same database. I'd like to display all the data in these 6 tables and display it in the browser as a single table. So I used full inner join for this purpose. I tried the code below, but its throwing an error like "mysql_num_rows() expects parameter 1 to be resource, boolean".

$sql ="SELECT * FROM table1 INNER JOIN table2 ON table1.pk1=table2.fk2 
        INNER JOIN  table3 ON table1.pk1=table3.fk3 INNER JOIN 
        table4 ON table1.pk1=table4.fk4 INNER JOIN table5 ON 
        table1.pk1=table5.fk5 INNER JOIN table6 ON table1.pk = table6.fk6";

$result = mysql_query($sql);
if (mysql_num_rows($result) > 0) { 
while($row = mysql_fetch_array($result)) { //display function
}

And is it possible to use full outer join in mysql.?

akshay
  • 1
  • 2
  • http://stackoverflow.com/questions/7766418/mysql-num-rows-expects-parameter-1-to-be-resource-boolean-given-in or http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-or-mysqli-result-boole – CularBytes Sep 05 '15 at 13:59

1 Answers1

0

The result will be a boolean in case of the query failing. What is the output if you add the following:

if($result === false) {
    var_dump(mysql_error());
}

Mysql doesn't support full joins however see https://stackoverflow.com/a/4796911/3691688 for workaround

Also, you should format your queries for them to be easier to read(eg. seperate joins to their own lines and use indets)

Community
  • 1
  • 1
touko
  • 1,957
  • 1
  • 11
  • 10