The problem is that I have the value of one column in the database, it is usually false , but it happens that it is empty, as I merge them into one output in the output. Those. values ​​of false 1000pcs, and with an empty value of 230pcs, merged into Not defined 1230pcs

The request itself is:

 $source_p = mysql_query("select ST.utm_term, ST.hash_person, COUNT(ST.utm_term) AS `stat_count`, count(distinct L.id) AS `lids_count`, count(distinct LL.id) AS `clients_count` FROM stat ST left join lids L on L.hash_person=ST.hash_person and L.id_cabinet = '$id_cabinet' $filtr_date_l and L.delete_status='0' left join leads_sort LS on LS.id_cabinet = $id_cabinet and LS.url = 'done' left join status S on LS.id_parameter = S.leadssort and S.id_cabinet = $id_cabinet left join lids LL on S.id = LL.status and LL.hash_person = ST.hash_person and L.id_cabinet = '$id_cabinet' $filtr_date_ll and LL.delete_status = '0' WHERE ST.id_cabinet=$id_cabinet $filtr_date_st GROUP BY `utm_term` ORDER BY `clients_count` DESC"); 

here's how to combine this

enter image description here

  • add in where name_field = 0 and name_field = 'false' - Naumov
  • I do not understand, I have a table displayed, displays two lines Not defined and empty ... and what it is where `` and where to add it - Alexander Sizintsev
  • not a ride! if he does this he shows only one field - Alexander Sizintsev
  • added image - Alexander Sizintsev
  • No, do it right in the app. If it is critical for you to get the correct result from the database, then proapdeyte one type of results, so that all were the same. - etki

1 answer 1

Perhaps so (check there is no possibility): replace

 COUNT(ST.utm_term) AS `stat_count` 

on

 COUNT(IF(ST.utm_term = '', false, ST.utm_term)) AS `stat_count` 
  • thanks, great solution - Alexander Sizintsev