开发者

SQL wildcard matching excluding a specific pattern

sorry about the question I am a newbie to sql. i am attempting to create a search query for our database and I was wondering how would you filter certain words from your query for example:

Here is the sample data (the name column): Jean, Jain, Joan, Jorn, Juan, John, Juin

Lets say that we are searching for the names that start with "J" and end with "n" but we don't want to include "John".

SELECT id, name
FROM tblusers
WHERE name LIKE 'j__n'
WHERE name NOT LIKE 'John'

Obviously the above will have an error, so I was wondering how do I correctly wr开发者_开发知识库ite the above.

Thanks in advance.


SELECT id, name
FROM tblusers
WHERE name LIKE 'j%n' 
AND name NOT LIKE 'John'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜