Forum Moderators: open

Message Too Old, No Replies

Need Help with a Complicated WHERE Clause

         

Tehuti

10:06 pm on Sep 14, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



Here's my SELECT statement:

SELECT

adv,
advlogo,
advurl,
cat,
caturl,
instr,
blockanch,
anch,
gotourl,
code,
DATE_FORMAT(expdate, '%d %M, %Y') AS formated_date,
expun

FROM tadv, tcat, tinstr, tcoupon

LEFT JOIN texpun on tcoupon.expunid=texpun.expunid

WHERE

tcoupon.advid=tadv.advid AND
tcoupon.catid=tcat.catid AND
tcoupon.instrid=tinstr.instrid;

I want to add the following but it doesn't work:

AND type='a' ¦¦ type='c';

Funny thing is, it works without all the other WHERE clauses. For example:

SELECT * from tcoupon WHERE type='a' ¦¦ type='c';

Anyone know how to add it on successfully?

[edited by: Tehuti at 10:07 pm (utc) on Sep. 14, 2008]

Tehuti

4:57 am on Sep 15, 2008 (gmt 0)

10+ Year Member Top Contributors Of The Month



I've found the answer for this one, guys. Apparently, all I have to do is enclose the last bit in parentheses, thus:

SELECT . . . WHERE . . . AND
tcoupon.catid=tcat.catid AND
tcoupon.instrid=tinstr.instrid AND
(type='a' ¦¦ type='c');