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

Posted by Frankie on 05/19/07 12:57

Hi Tyno
you could try

SELECT
COUNT(modpr_prereq or null) as prereq_count,
COUNT(mods_slide or null) 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;

Frankie
http://puity.com


"Tyno Gendo" <you@localhost> a ιcrit dans le message de news:
SIednU9JC4YG7dTbRVnytgA@bt.com...
> 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

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация