Forum Moderators: coopster
It's looking like this:
SELECT * FROM freehosted WHERE website='$website' AND type='FHG' AND category='$category' OR keywords LIKE '%$category%'
This is working good, however I ONLY want the website designated in the $website variable to display.
Right now it's displaying all over the map, if 1 variable matches it displays the record.
I want it to search like this:
Specific Website only
Type = FHG only
Category or keywords = Category (not only)
So basically the website and type have to be specifically as requested and the category just has to include it amongst other keywords/categories.
I really hope this can be done by select and not have to be broken down by some scripting or something. If so, please help me out here. I'm not NEW but I'm not professional by far.
Thanks a ton!
I think what you want to do here is group some of your statements. There is an "order of operations" in SQL just like in algebra. In your case that OR is allowing anything to match because it's not clear to the SQL engine you intend it to be an OR that only relates to the category match. Try this code:
SELECT * FROM freehosted WHERE website='$website' AND type='FHG' AND ( category='$category' OR keywords LIKE '%$category%' )