Re: mySQL SQL query

From: Date: Fri, 06 Aug 2004 19:29:21 +0000
Subject: Re: mySQL SQL query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-193058@lists.php.net to get a copy of this message
On Thu, 5 Aug 2004 08:48:01 -0500, Jay Blanchard <jay.blanchard@niicommunications.com> wrote:
[snip] [snip] A quickie for you: How do I say SELECT * FROM mytable where the sum of this field + this field + this field < x I can't say I've done one of those before. [/snip] How many SQL queries can a PHP list handle in a day? More than the MySQL list! Hahahahahaha! SELECT a + b + c and myTotal FROM myTable HAVING myTotal < x [/snip] Sorry, syntax errors.... SELECT a + b + c AS myTotal FROM myTable HAVING myTotal < x you can also do this SELECT (SUM(foo) + SUM(bar)) AS myTotal FROM myTable GROUP BY thisThing HAVING myTotal < x
Just say SELECT * FROM Table WHERE Table.a + Table.b + Table.c < x That should work, and it will be faster than using a HAVING clause. Brian

« previous php.general (#193058) next »