Reputation: 233
While practicing ORACLE SQL query, i stumbled upon a simple question of returning records with name containing a certain word like 'Jackson'.
I used a where clause :
where NAME like 'Jackson %' and NAME like '% Jackson %';
Is there a simpler or shorter way to do this?
Sorry for the confusing title and this noob question. Feel free to change. Thank you.
RECORD:
RESULTS:
Upvotes: 0
Views: 66
Reputation: 1269823
You can do this as:
where NAME like '%Jackson %'
The %
wildcard can match no characters at all.
If you want to find the word "Jackson" anywhere in the string (so it doesn't match, say, "Smith-Jackson"), then do:
where ' '||NAME||' ' like '% Jackson %'
Upvotes: 1