我有 5 个表:a、b、c、d 和 e。
每个表都由 id 字段上的 INNER JOIN 连接。
我的查询工作正常,但我需要增强它以计算结果,以便我可以将其回显到屏幕上。我无法让计数工作。
我正在查询非常具体的字段:
state_nm
status
loc_type
这些是我手动输入查询的所有参数,如下所示:
$_POST["state_nm"] = 'AZ'; ... // and for all other below values..
SELECT *
FROM main_table AS a
INNER JOIN table_1 AS b ON a.id = b.id
INNER JOIN table_2 AS c ON b.id = c.id
INNER JOIN blm table_3 AS d ON c.id = d.id
INNER JOIN table_4 AS e ON d.id = e.id
WHERE a.trq != ''
AND b.state_nm = '".$_POST["state_nm"]."'
AND b.loc_type LIKE \ "%".$_ POST ["loc_type"]."%\"
AND b.STATUS = '".$_POST["status"]."'
GROUP BY b.NAME
ORDER BY c.county ASC;