String Searching

andy1210

Registered User.
Local time
Today, 06:04
Joined
Mar 14, 2006
Messages
15
I have a problem with an SQL query that is used to create a report, the query itself works fine, however I need to get it to do something extra. Basically we have a column that contains 1-3 letters. The letters are A, B and C. The query searches the database and returns result depending on which of the letters we entered. We do this using the like statment -:

SELECT * FROM TableUser WHERE UserType LIKE B

So the above SQL statement returns all entries with the letter B in the column UserType. Also we my need to search for AB, which returns all entries with AB and ABC. The problem is that we sometimes need to search for AC, which should return the values AC and ABC. The problem is that it only returns the values AC and not ABC. I know why it does this as it is searching for a string like 'AC', I am just not sure how to get round the problem. Is there a way of searching the string for the Value AC so that it returns the entries AC and ABC.
Thanks in advance for any help.
Cheers
Andy
 
I wouldn't be holding multiple data like that, but there you go. I'm not that keen on using LIKE either. Try this.

SELECT * FROM TableUser WHERE UserType = "ABC" or UserType="AC"
 

Users who are viewing this thread

Back
Top Bottom