Implicit Cross Join in PHP

In this article I explain how to use implicit cross join in PHP
  • 1925


A  CROSS JOIN produce a result set in which each row from the first table is combined with each rows from the second table. Cross Join is also called Cartesian Product. Cross join have two types

  • Implicitly Cross Join
  • Explicitly Cross Join

Implicitly Cross Join

In implicit cross join you do not require to write the cross join keywords after the first table name and before the second table name, you can simple write select statement and pass table names and all names will be separate bycommas in from clause.


SELECT select_list
FROM table1, table2

Example of Implicit Cross Join in PHP



if (!$con)


  die('Could not connect: ' . mysql_error());


mysql_select_db("mysql", $con);


print "<h2>MySQL: Cross Join Implicitly</h2>";

$result = mysql_query("select fname,role from emp, designation ");

echo "<table border='1'>






while($row = mysql_fetch_array($result))


   echo "<tr>";

   echo "<td>" . $row['role'] . "</td>";

   echo "<td>" . $row['fname'] . "</td>";


  echo "</tr>";


  echo "</table>"; 





© 2020 DotNetHeaven. All rights reserved.