|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
||||
|
||||
|
SQL syntax help
Hi, I know that this query to the db works:-
[MYSQL] select * from table where ((Name LIKE \"%$trimmed%\") AND (Category1 NOT LIKE \"Banner*****\")); [/MYSQL] but when I add another term, it stop working [MYSQL] select * from table where ((Name LIKE \"%$trimmed%\") AND ((Category1 NOT LIKE \"Banner*****\") OR (Category1 NOT LIKE \"Affiliates%\"))); [/MYSQL] what I am doing wrong? it seems quite correct to me! thanks |
|
#2
|
||||
|
||||
|
Try this:
Code:
select * from table where ((Name LIKE \"%$trimmed%\") AND (Category1 NOT LIKE \"Banner*****\")) OR (Category1 NOT LIKE \"Affiliates%\"); I rearranged your brackets a bit.
__________________
Daryl's Homepage | My Blogroll | My Profile | Firefox supporter! DevArticles Forum Moderator "The net is a waste of time, and that's exactly what's right about it." -- William Gibson |
|
#3
|
||||
|
||||
|
Thanks Dzz
Oooooh I see! It's abit like saying "select anything like this but not like this.....oh! by the way, OR not like that as well ; if I wanted to add another conditional NOT LIKE would I do it like this? Code:
select * from table where ((Name LIKE \"%$trimmed%\") AND (Category1 NOT LIKE \"Banner*****\")) OR (Category1 NOT LIKE \"Affiliates%\" OR Category1 NOT LIKE \"something\"); |
|
#4
|
||||
|
||||
|
Quote:
Don't think I'm not grateful, but I found this works actually Code:
((Name LIKE \"%$trimmed%\") AND ((Category1 NOT LIKE \"Banner*****\") AND (Category1 NOT LIKE \"Affiliates%\"))) cheers anyway |
|
#5
|
||||
|
||||
|
I was just going by what you had and blindly pretended I knew the data =)
Kudos for figuring it out and thanks for following up! |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > SQL syntax help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|