Reputation: 87
I have to write a query which checks for a field "zone" and its value in one of the rows is "inter/intra". I need to query this field to retrieve its value. Something like
select id from table where zone = 'inter/intra'
OR
select id from table where zone like 'inter/intra'
However this query is failing everytime.
Please tell me the right query for this.
Upvotes: 0
Views: 43
Reputation: 738
When you use like, you need to add wildcards: the % symbol represents any arbitrary string. For example this will find the id of the record where zone contains "inter/intra":
select id from table where zone like '%inter/intra%'
This will find the id of the record where zone starts with "inter/intra":
select id from table where zone like 'inter/intra%'
This will find the id of the record where zone ends with "inter/intra":
select id from table where zone like '%inter/intra'
Upvotes: 2