Can you SUM(IF) from two different tables at the same time?

From: Date: Mon, 27 May 2002 23:32:57 +0000
Subject: Can you SUM(IF) from two different tables at the same time?
Groups: php.db 
Request: Send a blank email to php-db+get-19461@lists.php.net to get a copy of this message
Hi all, I'm using the following two queries: 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 total FROM message This literally brings back a total number of threads and messages posted to the two respective boards (boardid1 and 2). All I am wondering is if this can be combined into a single query or does the very nature of using the SUM(IF) not allow this to happen? Regards, Richard -- Fatal Design http://www.fatal-design.com Atari / DarkBASIC / Coding / Since 1995

« previous php.db (#19461) next »