Reputation: 393
I have a table which contains information on places to fish. I have a column called species. its contents may be similar to:
Brown & Rainbow Trout, Pike
How do i write a statment that would show all fisheries that have 'pike' in the species column? something like:
SELECT species from table WHERE species='Pike'
of course this statment wont work becuase the species colomn contains more than just 'Pike'
Any suggestions? Without creating a column for each species.
Upvotes: 2
Views: 1566
Reputation: 247680
Using LIKE
instead of =
in the WHERE
clause below allows you match all species
values that contain 'Pike'. It is a wild card search.
SELECT species
FROM yourTable
WHERE species LIKE '%Pike%'
Upvotes: 3
Reputation: 227240
Try using LIKE
. (%
means match 0 or more characters, _
means match one character.)
SELECT species from table WHERE species LIKE '%Pike%'
Upvotes: 5