简体   繁体   English

计算查询的行在所有表上出现多少次

[英]count how many times a row from a query appear on all the table

I have this query it's work fine 我有这个查询,它工作正常

  $con    = "SELECT     id, fecha, id_px FROM mytable WHERE date='$fe' AND id_nut='$id' AND id_suc = '$su' AND confirm != '3'

but i need know how many times appear each id_px resultant from this query on the table regardless the date and whith other criteria 但是我需要知道此查询在表上产生的每个id_px结果出现多少次,而不管日期和其他条件如何

something like this query 像这样的查询

 SELECT id_px, paciente, id FROM consultas2 WHERE id_px='$id_px' AND cobrado=1 LIMIT 22  

the final result i need is all the data from the first query like this 我需要的最终结果是像这样的第一个查询中的所有数据

$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--
);

how can achieve that? 如何实现呢? thanks in advance! 提前致谢!

这将为您提供与$ id_px相匹配的结果总数

SELECT count(*) FROM consultas2 WHERE id_px='$id_px' AND cobrado=1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM