Topic awaiting preservation: mySQL: trying to count rows where bit_count in SET > 0 (Page 1 of 1) |
|
---|---|
Nervous Wreck (II) Inmate From: East Anglia, England. |
posted 09-17-2004 11:18
I'm not sure if there are any mySQL guru's out there, but I'm struggling to sort out a query to count how many rows have some or all of the items in a SET field. code: SELECT
|
Maniac (V) Mad Scientist From: :morF |
posted 09-17-2004 16:35
possibly 'WHERE BIT_COUNT != null'. I believe when a set field has none of it's set values selected the database registers it as null. |
Nervous Wreck (II) Inmate From: East Anglia, England. |
posted 09-18-2004 11:41
I've been labouring at this and have come up with a solution, not exactly what I wanted but it works. It requires a loop to process the data, which I still think I can avoid if my mySQL query knowledge was good enough. code: "SELECT |
Maniac (V) Mad Scientist From: :morF |
posted 09-18-2004 12:19
you know...I just had a thought...why not just tell it to select all records that have at least one of the options selected and then, instead of using that loop to count them count like this: code: $count = mysql_num_rows($result); |
Neurotic (0) Inmate Newly admitted From: |
posted 09-19-2004 18:55
Skaarj, in SQL, the correct syntax for determining null values in the database is "colname IS NULL" or "colname IS NOT NULL". I would make sure I know this stuff before I try helping people. code: while (list($items, $count) = mysql_fetch_row($res)) {
code: // all rows in the column
|
Maniac (V) Mad Scientist From: :morF |
posted 09-20-2004 10:15
Well, while we're all giving out friendly advice, here's a little for you: |
Nervous Wreck (II) Inmate From: East Anglia, England. |
posted 09-20-2004 10:40
Ouch... broken fingers for using extract() over list()... that's a tough penalty for such a small change. |
Maniac (V) Inmate From: raht cheah |
posted 09-20-2004 16:58
quote:
|
Maniac (V) Mad Scientist From: :morF |
posted 09-20-2004 17:45
My apologies then JK. I do try not to flaunt my position around here, but the whole tone of that post got up my nose. |