Andreamcc Posted February 25, 2020 Share Posted February 25, 2020 Hi All, I am wondering if someone could help me figure out some SQL code. For an assignment question on a SQL database i need to return any names which have 'an' in them e.g Andy but I don't want to return any names with and e.g Jones and Co. I understand the like '%an%' but it is also returning the 'and' strings. How can I get around this? Many thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted February 25, 2020 Share Posted February 25, 2020 That's why came up with NOT LIKE Link to comment Share on other sites More sharing options...
Makwana Prahlad Posted March 2, 2020 Share Posted March 2, 2020 select * from [TableName] where [ColumnName] Like '%an%' and not [ColumnName] Like '%and%' Hi, Try this, i hope this will work. Link to comment Share on other sites More sharing options...
dsonesuk Posted March 2, 2020 Share Posted March 2, 2020 Its columnname NOT LIKE, and using '%and%' means Andrew won't be selected, use '% and %' instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now