[PHP-DB] Re: Can you SUM(IF) from two different tables at the same time?

2002-05-28 Thread Hugh Bothwell
"Richard Davey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > In the 5th line I changed "thread.id" to "thread.threadid" so the name was > correct but the same error occurs. Ok, I was guessing at your field names... > to give a perfectly satisfactory res

[PHP-DB] Re: Can you SUM(IF) from two different tables at the same time?

2002-05-28 Thread Richard Davey
"Hugh Bothwell" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Instead, you want a query which returns a record > with "thread count" and "message count" for each > group. > > SELECT > COUNT(DISTINCT threadid) AS threads, > COUNT(*) AS messages > FROM >

[PHP-DB] Re: Can you SUM(IF) from two different tables at the same time?

2002-05-28 Thread Hugh Bothwell
"Richard Davey" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > 1. SELECT SUM(IF(boardid='2',1,0)) AS b2, SUM(IF(boardid='1',1,0)) AS b1, > COUNT(*) AS total FROM thread > > 2. SELECT SUM(IF(boardid='2',1,0)) AS b2, SUM(IF(boardid='1',1,0)) AS b1, > COUNT(*) AS