我有这个查询它工作正常
$con = "SELECT id, fecha, id_px FROM mytable WHERE date='$fe' AND id_nut='$id' AND id_suc = '$su' AND confirm != '3'
但我需要知道,无论日期和其他标准如何,每个id_px
来自此查询的结果会显示多少次
类似这样的查询
SELECT id_px, paciente, id FROM consultas2 WHERE id_px='$id_px' AND cobrado=1 LIMIT 22
我需要的最终结果是来自第一个查询的所有数据,如此
$consultas = array(
'id' => $tim['id'],
'id_nutr' => $tim['id_nut'],
'date' => $tim['date'],
--this is the data i need-->
'total_cns' =>$tim['?']
--the total of num rows of the second query--
);
怎么能实现呢? 提前谢谢!
答案 0 :(得分:0)
这将为您提供与$ id_px匹配的结果总数
SELECT count(*) FROM consultas2 WHERE id_px='$id_px' AND cobrado=1