|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
On Wed, 03 Oct 2007 16:18:08 +0200, turnitup <same@same> wrote:
> I want to include an AND clause, but only if a certain criteria is met.. > There are other AND clauses. Pseudo code below > > SELECT * from tbl where foo = 1 AND bar = 1 AND IF ( (asas != 1)asas > > 2 ) > > Is this possible? SELECT * from tbl WHERE foo = 1 AND bar = 1 AND (asas = 1 OR asas > 2) -- Rik Wasmus |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
Rik Wasmus wrote:
> On Wed, 03 Oct 2007 16:18:08 +0200, turnitup <same@same> wrote: > >> I want to include an AND clause, but only if a certain criteria is >> met. There are other AND clauses. Pseudo code below >> >> SELECT * from tbl where foo = 1 AND bar = 1 AND IF ( (asas != 1) asas >> > 2 ) >> >> Is this possible? > > SELECT * from tbl > WHERE foo = 1 > AND bar = 1 > AND (asas = 1 > OR asas > 2) > --Rik Wasmus THank you both, that may have just done the trick. |
|
![]() |
| Outils de la discussion | |
|
|