Reputation: 197
So I am starting SQL and I have the following query
Select * from Material where theme = 'math' or name = 'math';
As far as I know this gets me the values that actually have that exact string 'math' on the theme or on the name. How do I put it if I want that value i.e 'math' also as a substring of the attributes theme or name.
Upvotes: 0
Views: 143
Reputation: 360902
Simplest method is to use a wildcard match using the LIKE
operator:
WHERE theme LIKE '%math%' // math appears anywhere in the string
WHERE theme LIKE 'math%' // math appears at the START of the string
WHERE theme LIKE '%math' // math appears at the END of the string
Upvotes: 2
Reputation: 2860
Select * from Material where theme LIKE '%math%' or name LIKE '%math%';
I believe you are interested in using the LIKE
operator.
Upvotes: 2