Reputation: 81
Looking at this link: SQL SELECT LIKE
What if you were searching for a name that starts with H
and ends with dinger
?
Would I use:
SELECT NAME LIKE
'H_dinger'
'H...dinger' or
'H%dinger' ?
I'll assume H_dinger
would think there is only 1 character in between, but I don't know what it is -- so I'm searching for it.
H...dinger
isn't valid.
And H%dinger
seems like it would check it all, but on the site, that isn't even listed?
Upvotes: 0
Views: 55
Reputation: 882048
You would use %
, which is the variable-sized wildcard.
But you need to get the syntax right, such as with:
select NAME from TABLE where NAME like 'H%dinger'
Keep in mind that queries using %
may be a performance issue (depending on how it's used and the DBMS engine). It can prevent the efficient use of indexes to speed up queries. It probably won't matter for small tables but it's something to keep in mind if you ever need to scale.
Upvotes: 2