andrew anderson
andrew anderson

Reputation: 393

Select (keyword) from table

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

Answers (3)

Taryn
Taryn

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

gen_Eric
gen_Eric

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

Nicola Cossu
Nicola Cossu

Reputation: 56357

SELECT species from table WHERE species like '%pike%'

Upvotes: 4

Related Questions