database - How to count all row result as 1 in mysql? -


I have two tables "TBLA", which includes areas of patient and hospital, and "TBL B" which is now in consultation My problem only counts the patient, which is in 4 records "tbl_b" so that if a patient has 4 records in "TBL B" then it is counted as 1. I should use this result only in mysql coz and I need this to run in the event scheduler. In short, I want to count all those patients who have 4 consultations in every hospital. Can anyone help me on this?

Use this solution:

  Patient by selecting the patient Choose. (1) & gt; = 4   

& gt; = to = and if you just want those patients who have absolutely instead of four or more, four consultations .

Perhaps you have count who has four or more consultations ... in this case you can wrap up the SELECT You can calculate the number of rows and:

  SELECT COUNT (1) from the patient (by selecting patient from Tbl_b group, COUNT) (1)> = 4) One    

Comments