Re: Select AND IF
turnitup <same@same> wrote in
<4703a447$0$13932$fa0fcedb@news.zen.co.uk>:
> I want to include an AND clause, but only if a certain
> criteria is met. There are other AND clauses. Pseudo code
> below
AND is not a clause. It's a boolean operator (or, in terms
of MySQL docs, 'logical operator'). So is OR. See 11.2.4 in
MySQL 5.0 Reference Manual.
> SELECT * from tbl where foo = 1 AND bar = 1 AND IF ( (asas
> != 1) asas >
> 2 )
SELECT * FROM tbl WHERE foo=1 AND bar = 1 AND (asas=1 OR
asas>2)
--
It is rare to find learned men who are clean, do not stink,
and have a sense of humour. -- Liselotte in a letter to
Sophie, 30 Jul 1705
|