PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old July 19th, 2004, 09:01 AM
tarka tarka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 tarka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
count or select ONLY the populated rows in a column?

I'm trying to COUNT the number of populated rows within a column named, 'column_03', but first instead of using COUNT i'm using SELECT to see where the numbers are coming from.

with the following code.......
first i'm selecting from 'column_01'
then i'm selecting from 'column_02'
finally i''m selecting from 'coulmn_03, (but only rows that are populated with info)

Code:
SELECT column_03
FROM table_name
WHERE table_name.column_01 = 'IN''
AND table.name.column_02 ='GENER"


the result is a total number of 10 records. i can see that 'column_03' has 6 rows that are populated and 4 rows are empty.

now what i want to do is select only the 6 rows that are populated, once i now how to do that i can then use COUNT.

after searching through google i came up with this variation.....

Code:
SELECT (NULL) column_03
FROM table_name
WHERE table_name.column_01 = 'IN''
AND table.name.column_02 ='GENER


and that didn't work, i get a result thats kinda weird, but logically thinking about it ...if it did work, by specifying NULL would I be asking to SELECT the rows that are EMPTY??? doesn't seem to be asking for just the populated rows????

i didn't realise that such a simple request could be so hard!

Reply With Quote
  #2  
Old July 19th, 2004, 09:12 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Wouldn't you want to just do something like this?

Code:
SELECT COUNT(*)
FROM table_name
WHERE table_name.column_01 = 'IN'
AND table.name.column_02 ='GENER'
AND column_03 IS NOT NULL
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old July 19th, 2004, 11:07 AM
tarka tarka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 tarka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i've used the COUNT and SELECT variations and i get the same results.

this one still selects 10 rows, 4 that i can see are empty and 6 that have (alpha string) values

Code:
SELECT column_03
FROM table_name
WHERE table_name.column_01 = 'IN''
AND table_name.column_02 ='GENER"
AND table_name.column_03 IS NOT NULL


this one provides a total count of 10

Code:
SELECT count(*)
FROM table_name
WHERE table_name.column_01 = 'IN''
AND table_name.column_02 ='GENER"
AND table_name.column_03 IS NOT NULL


do you think it could be something to do with the way column_03 is set up, as NULL or NOT NULL?? initially it was set up as NOT NULL so i copied the table structure changing column_03 to NULL, then re-imported the data ....but i get the same results on both types of columns.

I just don't understand whats going on???

Reply With Quote
  #4  
Old July 19th, 2004, 11:22 AM
tarka tarka is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 15 tarka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
for all you crazy kids out there .....i solved it with this....

Code:
SELECT column_03
FROM table_name
WHERE table_name.column_01 = 'IN'
AND table_name.column_02 ='GENER'
AND table_name.column_03 <> ''

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > count or select ONLY the populated rows in a column?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway