不知道是不是这个意思SQL> select * from a01;COL1 -------------------- A01B01CC A02B02CC A03B03CC A02D02CCSQL> accept A char prompt "input the A:" input the A:A SQL> accept B char prompt "input the B:" input the B:B SQL> accept C char prompt "input the C:" input the C:C SQL> select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%'; old 1: select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%' new 1: select * from a01 where col1 like 'A'||'__'||'B'||'__'||'C'||'%'COL1 -------------------- A01B01CC A02B02CC A03B03CCSQL> accept B char prompt "input the B:" input the B:D SQL> select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%'; old 1: select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%' new 1: select * from a01 where col1 like 'A'||'__'||'D'||'__'||'C'||'%'COL1 -------------------- A02D02CCSQL>
是要这样子的吗?with t as ( select 'C123abcJ456defYY' as fname from dual union all select 'C45efJ12bcYX' from dual union all select 'CC456def123abcY' from dual ) select * from t where regexp_like(fname,'C[0-9a-zA-z]+J[0-9a-zA-z]+Y[A-Z]+')FNAME ---------------- C123abcJ456defYY C45efJ12bcYX
--------------------
A01B01CC
A02B02CC
A03B03CC
A02D02CCSQL> accept A char prompt "input the A:"
input the A:A
SQL> accept B char prompt "input the B:"
input the B:B
SQL> accept C char prompt "input the C:"
input the C:C
SQL> select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%';
old 1: select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%'
new 1: select * from a01 where col1 like 'A'||'__'||'B'||'__'||'C'||'%'COL1
--------------------
A01B01CC
A02B02CC
A03B03CCSQL> accept B char prompt "input the B:"
input the B:D
SQL> select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%';
old 1: select * from a01 where col1 like '&A'||'__'||'&B'||'__'||'&C'||'%'
new 1: select * from a01 where col1 like 'A'||'__'||'D'||'__'||'C'||'%'COL1
--------------------
A02D02CCSQL>
select 'C123abcJ456defYY' as fname from dual
union all
select 'C45efJ12bcYX' from dual
union all
select 'CC456def123abcY' from dual
)
select * from t
where regexp_like(fname,'C[0-9a-zA-z]+J[0-9a-zA-z]+Y[A-Z]+')FNAME
----------------
C123abcJ456defYY
C45efJ12bcYX