-1

有人可以帮助我如何在 sql 语句中选择电话数组,其中电话是数组

创建类型 phone 作为 varchar2(13) 的 varray (3);

从 person_table 中选择姓名、电话,其中 value(p) 为 (type) 且 ( phone 以“0770”开头);

4

1 回答 1

1

看看这个样本:

Create type phone_v as varray (3) of varchar2(13); --type creation
Create table person (name varchar2(100),phone phone_v); --table creation

--table data
insert into person values ('John',phone_v('0770 12','0789 00','0101'));
insert into person values ('David',phone_v('1','1','1'));

现在您可以执行以下操作:

select * from person per
where exists (select 1 from table(per.phone) where column_value like '%0770%');

此查询获取电话号码包含的所有人的数据0770,如果您想要以该号码开头的电话,只需将类似表达式更改为0770%

于 2015-03-17T15:04:00.400 回答