![]() 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. |
![]() 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 |
![]() 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. |
![]() 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 |
![]() 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: |
![]() 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 |
![]() Well, while we're all giving out friendly advice, here's a little for you: |
Nervous Wreck (II) Inmate From: East Anglia, England. |
![]() Ouch... broken fingers for using extract() over list()... that's a tough penalty for such a small change. |
Maniac (V) Inmate From: raht cheah |
![]() quote:
|
Maniac (V) Mad Scientist From: :morF |
![]() 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. |