mysql count not working with join and where clause -


if using query:

select clinic.id clinic  join dentist on dentist.id = clinic.dentist_id  join user on user.id = dentist.user_id  user.status = 'active' , clinic.status = 'approved' , user.role_id = 2 group clinic.id; 

so gives me rows like

32 35 36 42 44 47 50 

bug if going total count of results apply query :

select count(clinic.id) cnt clinic  join dentist on dentist.id = clinic.dentist_id  join user on user.id = dentist.user_id  user.status = 'active' , clinic.status = 'approved' , user.role_id = 2 group clinic.id; 

i applied count() id, , returns

1 1 1 1 1 1 1 

it not returns 7, want result 7. can guide please.

do not use group by or try this

select clinicid,sum(case when clinic !=null 1 else null end).id cnt clinic  join dentist on dentist.id = clinic.dentist_id  join user on user.id = dentist.user_id  user.status = 'active' , clinic.status = 'approved' , user.role_id = 2 group clinic.id; 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -