Reputation: 257
I need your help with a simple query that I have but not sure how change the LIKE wildcard accordingly. This to query an Oracle database.
Could you please assist with the below,
select * from table_name
where field1 like '1%'
or field2 like '2%'
or field3 like '3%'
or field4 start with 4 but not 4123
Upvotes: 1
Views: 111
Reputation: 16407
Here is an alternate approach:
select *
from table_name
where
substr (field1, 1, 1) in ('1', '2', '3', '4') and
field1 not like '4123%'
Upvotes: 0
Reputation: 184
select *
from table_name
where field1 like '1%'
or field2 like '2%'
or field3 like '3%'
or (field4 like '4%' and field4 not like '4123%')
Upvotes: 4