What are the potential pitfalls of joining tables in SQL queries in PHP?

Potential pitfalls of joining tables in SQL queries in PHP include creating Cartesian products if the join condition is not specified correctly, causing the query to return incorrect results or slow down performance. To avoid this, always specify the join condition explicitly to ensure the correct data is retrieved.

$query = "SELECT * FROM table1 
          JOIN table2 ON table1.id = table2.table1_id";
$result = mysqli_query($connection, $query);