You are here: Count() multiple columns « PHP SQL « IT news, forums, messages
Count() multiple columns

Posted by Tyno Gendo on 05/15/07 08:35

hi

i'm just wondering, is it possible to count the number of rows without
NULL/blanks in for two columns in one select?

I tried: SELECT module.*, COUNT( modpr_prereq ) AS prereq_count, COUNT(
mods_slide ) AS step_count FROM module LEFT JOIN mod_prereqs ON
mod_prereqs.modpr_mod = module.mod_seq LEFT JOIN mod_slide ON
mod_slide.mods_mod_seq = module.mod_seq GROUP BY mod_seq;

But this just returns same count for both prereq_count and step_count

I also tried to look at

SELECT prereq_count=(SELECT COUNT(*) FROM mods_prereqs),
step_count=(SELECT COUNT(*) FROM mods_slide) ....

MySQL doesn't support this 2nd style?

Is there any way to get two column counts and a set of data in one
SELECT under MySQL?

Thanks in advance for any help.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация