【问题标题】:How to LEFT JOIN more than 61 tables pup MySQL如何 LEFT JOIN 超过 61 个表 pup MySQL
【发布时间】:2022-06-17 01:33:54
【问题描述】:

我生成了一个大数据查询(一个查询)超过 61 个 LEFT JOIN 类型,现在我无法继续如何解决这个问题我需要添加更多表。

我的查询如下:

<?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 !"));


?>

另外,我的工作方式有问题吗?有没有更好的办法?这是否意味着查询会很慢?

【问题讨论】:

  • 我认为你应该重新审视你的数据库设计而不是尝试这个查询

标签: php mysql


猜你喜欢
  • 1970-01-01
  • 2011-12-20
  • 1970-01-01
  • 2013-04-19
  • 2016-07-21
  • 2016-12-16
  • 1970-01-01
  • 1970-01-01
  • 2013-02-20
相关资源
最近更新 更多