当我获取 aasoc 时,我需要从其他表中进行 4 次选择。它非常糟糕并且停止了驱动页面(。请告诉我是否可以提出一个请求而不是四个请求?
$sql_id_city = "SELECT * FROM City WHERE id_city='$id_city'";
$get_id_city = sqlsrv_query($conn, $sql_id_city);
$info_id_city = sqlsrv_fetch_array($get_id_city, SQLSRV_FETCH_ASSOC);
$name_city=$info_id_city['name'];
$id_producer_country=($i['id_producer_country']!='')? $i['id_producer_country']:'0';
$sql_id_producer_country = "SELECT * FROM Producer_country WHERE id_producer_country='$id_producer_country'";
$get_id_producer_country = sqlsrv_query($conn, $sql_id_producer_country);
$info_producer_country = sqlsrv_fetch_array($get_id_producer_country, SQLSRV_FETCH_ASSOC);
$name_producer_country=$info_producer_country['name'];
$id_firm=($i['id_firm']!='')? $i['id_firm']:'0';
$sql_id_firm = "SELECT * FROM Firm WHERE id_firm='$id_firm'";
$get_id_firm = sqlsrv_query($conn, $sql_id_firm);
$info_film = sqlsrv_fetch_array($get_id_firm, SQLSRV_FETCH_ASSOC);
$name_firm=$info_film['name'];
$phone_firm=$info_film['phone'];
$id_price=($i['id_price']!='')? $i['id_price']:'0';
$sql_id_cost = "SELECT * FROM Cost WHERE id_price='$id_price'";
$get_id_cost = sqlsrv_query($conn, $sql_id_cost);
$info_cost = sqlsrv_fetch_array($get_id_cost, SQLSRV_FETCH_ASSOC);
$cost=$info_cost['cost'];
$id_currency=$info_cost['id_currency'];
$id_sale=$info_cost['id_sale'];