大家好,我现在有一个表:ID NAME
1 A,B,C
2 B
3 B,C
现在我想查出所有包含A或C的记录,也就是第一条和第三条记录.
请问有什么好办法可以查出呢?(查询A或C只是个例子,实际上会有很多个的情况,比如:A、B、F、G...)
1 A,B,C
2 B
3 B,C
现在我想查出所有包含A或C的记录,也就是第一条和第三条记录.
请问有什么好办法可以查出呢?(查询A或C只是个例子,实际上会有很多个的情况,比如:A、B、F、G...)
解决方案 »
- 按出生日期和性别统计年龄段的人数
- 无法对所有EM相关账户解锁
- 还是分组的问题...求高手
- 请教大家 oracle 查询记录间隔最大记录数
- SQL server访问oracle的问题
- ORACLE9i中文版安裝文件,3CD的ISO光盤鏡像安裝不了,請高手指點,有分相送。
- utl_file.fseek(fid,absolte,relitive)怎么定位到文件第一行
- 怎样在查询记录时给记录加锁?
- 我用的Developer/2000开发,数据块里的"from子查询"是怎么用法?(特急!在线等待!)
- 请教sql/plus语句!高手相助!
- Oracle与sqlserver数据类型对应
- oracle 10g中日期数据的问题
with tmp as
(
select 1 id, 'A,B,C' name from dual
union all
select 2 id, 'B' name from dual
union all
select 3 id, 'B,C' name from dual
)
select id, name
from tmp
where regexp_like(name, '[A|C]'); ID NAME
---------- -------
1 A,B,C
3 B,C
(
select 1 id, 'A,B,C' name from dual
union all
select 2 id, '|' name from dual
union all
select 3 id, 'B,C' name from dual
)
select id, name
from tmp
where regexp_like(name, '[AC]')正则表达式[A|C]应该是指A,|,C其中一个;[AC]指A或C
(
select 1 id, 'A,B,C' name from dual
union all
select 2 id, 'B' name from dual
union all
select 3 id, 'B,C' name from dual
union all
select 4 id, 'a,c' name from dual
)
select id, name
from tmp
where regexp_like(name, '[AC]', 'i'); ID NAME
---------- -------
1 A,B,C
3 B,C
4 a,c
with tmp as
(
select 1 id, 'A,B,C' name from dual
union all
select 2 id, 'B' name from dual
union all
select 3 id, 'B,C' name from dual
union all
select 4 id, 'a,c' name from dual
)
select id, name
from tmp
where instr(name,'C',1) > 0;