I generated a large data query (one query ) more than 61 of type LEFT JOIN and now I can't continue how to solve this problem I need to add more tables.
My query is as follows:
<?php
require_once 'connt.php';
$id=$_GET['id'];
$sql="SELECT * FROM topics
LEFT JOIN #########
LEFT JOIN #########
LEFT JOIN #########
LEFT JOIN #########
LEFT JOIN #########
LEFT JOIN #########
LEFT JOIN #########
LEFT JOIN #########
..ect
where topics.id = ? " ;
$stmt = $con->prepare($sql);
$stmt->bind_param("s",$id);
$stmt->execute();
$result = $stmt->get_result();
$array = array();
while ($row = mysqli_fetch_assoc($result))
{
$array[] = $row;
}
echo ($result) ?
json_encode(array("code" => 1, "result"=>$array)) :
json_encode(array("code" => 0, "message"=>"Data not found !"));
?>
Also, is my way of working wrong? Is there a better way? Does this mean that the query will be slow?
Copyright Notice:Content Author:「M Al」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/72649793/how-to-left-join-more-than-61-tables-pup-mysql