Forums
This topic is locked
AND/OR/NOT queries
21 Nov 2001 12:45:54 Bec C posted:
How do I achieve the following<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle> have built a boolean search query that works fine except for when I search multiple fields.SELECT keywords, sport FROM imageTbl
WHERE keywords LIKE '%' & 'ball' & '%' OR sportname LIKE '%' & 'tennis' AND NOT keywords LIKE '%' & 'football' & '%'
I would like only records matching ball and tennis not football to be displayed. But if the record football contains keyword ball it is display.
Shouldnt the theory
ball or tennis not football firstly pull all ball and tennis records and then strip out further any records with football?
Any help would be great!
Replies
Replied 23 Nov 2001 23:52:53
23 Nov 2001 23:52:53 Tim Green replied:
If you are using MySQL then the correct syntax would be:-
SELECT keywords, sport FROM imageTbl
WHERE keywords LIKE '%ball%' OR sportname LIKE '%tennis%' AND NOT keywords LIKE '%football%'
Sorry, but I'm not sure if this is the same syntax for other DBMS...
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
SELECT keywords, sport FROM imageTbl
WHERE keywords LIKE '%ball%' OR sportname LIKE '%tennis%' AND NOT keywords LIKE '%football%'
Sorry, but I'm not sure if this is the same syntax for other DBMS...
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>