![](/img/trans.png)
[英]Display all records for mySQL field and count how many times they appear for specific date
[英]count how many times a row from a query appear on all the table
我有這個查詢,它工作正常
$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--
);
如何實現呢? 提前致謝!
這將為您提供與$ id_px相匹配的結果總數
SELECT count(*) FROM consultas2 WHERE id_px='$id_px' AND cobrado=1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.