so I want to
SELECT * from table where column like 'Something%' or like 'somethingelse%'
I tried it and get syntax errors because I don't think 'OR' is a command like 'AND' is or is it? I have been searching and yet to find any MS SQL statement that references it... So how is this done?
(right now I just have two statement and my PHP script puts them together bu thinking there has to be a better way)
Thanks for the clarification.
-- never mind found it that is should work -- must have been something wrong with my statement thats all.
Quote:
Originally Posted by sharijl
Can someone explain the correct way to query SQL with a like or statement.
so I want to
SELECT * from table where column like 'Something%' or like 'somethingelse%'
I tried it and get syntax errors because I don't think 'OR' is a command like 'AND' is or is it? I have been searching and yet to find any MS SQL statement that references it... So how is this done?
(right now I just have two statement and my PHP script puts them together bu thinking there has to be a better way)
Thanks for the clarification.
Your code is nearly fine. Think of 'like' as '=' for a moment: you need two sides two each comparison: a='foo' OR a='bar'. Same applies here: SELECT * from table where column like 'Something%' or column like 'somethingelse%'
It's usually good practice to add parentheses, though not required.|||OH so thats it... I forgot to state the name of the column again... -- thanks
No comments:
Post a Comment