Re: Mysql SELECT IF()

2002-06-19 Thread Paul B van den Berg
On 18 Jun 2002 at 16:36, Walter D. Funk wrote: > Hi everybody! > > I need to count the ACTIVE users of my Mysql users table; where 'active' is > a flag showing this status, > using the following query it returns all the user in the table, and I need > only those who have tha flag active set to '

Re: Mysql SELECT IF()

2002-06-18 Thread Keith C. Ivey
On 18 Jun 2002, at 17:36, João Paulo Vasconcellos wrote: > SELECT SUM( IF( STRCMP( active,'Y' ) = 0, 1, 0 ) ) as activeUsers > FROM usersTbl Since comparisons return 1 or 0, a simpler way of writing that query is SELECT SUM( active = 'Y' ) as activeUsers FROM usersTbl (although things are m

Re: Mysql SELECT IF()

2002-06-18 Thread João Paulo Vasconcellos
You may try: SELECT SUM( IF( STRCMP( active,'Y' ) = 0, 1, 0 ) ) as activeUsers FROM usersTbl On Tuesday 18 June 2002 16:36, Walter D. Funk wrote: > Hi everybody! > > I need to count the ACTIVE users of my Mysql users table; where 'active' is > a flag showing this status, > using the followi