我需要您的帮助,我有一个简单的查询但不确定如何相应地更改LIKE通配符。这用于查询Oracle数据库。
请你帮忙解决下面的问题,
select * from table_name
where field1 like '1%'
or field2 like '2%'
or field3 like '3%'
or field4 start with 4 but not 4123
答案 0 :(得分:4)
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%')
答案 1 :(得分:0)
这是另一种方法:
select *
from table_name
where
substr (field1, 1, 1) in ('1', '2', '3', '4') and
field1 not like '4123%'