select b.query_id, B.QUERY_NO
from (select '22214266' tel_no
from dual
union all
select '22214266' tel_no from dual) A,
(select '152' query_id, '(020)22214266' query_no, 'U' query_type
from dual
union all
select '153' query_id, '(020)22214266' query_no, 'U' query_type
from dual) B
where B.QUERY_TYPE = 'U'
and SUBSTR(B.QUERY_NO, INSTR(B.QUERY_NO, ')') + 1) = A.TEL_NO(+)
and b.query_no = '(020)22214266';select b.query_id, B.QUERY_NO
from (select '22214266' tel_no
from dual
union all
select '22214266' tel_no from dual) A,
(select '152' query_id, '(020)22214266' query_no, 'U' query_type
from dual
union all
select '153' query_id, '(020)22214266' query_no, 'U' query_type
from dual) B
where B.QUERY_TYPE = 'U'
and b.query_no = A.TEL_NO(+)
and b.query_no = '(020)22214266';
from (select '22214266' tel_no
from dual
union all
select '22214266' tel_no from dual) A,
(select '152' query_id, '(020)22214266' query_no, 'U' query_type
from dual
union all
select '153' query_id, '(020)22214266' query_no, 'U' query_type
from dual) B
where B.QUERY_TYPE = 'U'
and SUBSTR(B.QUERY_NO, INSTR(B.QUERY_NO, ')') + 1) = A.TEL_NO(+)
and b.query_no = '(020)22214266';select b.query_id, B.QUERY_NO
from (select '22214266' tel_no
from dual
union all
select '22214266' tel_no from dual) A,
(select '152' query_id, '(020)22214266' query_no, 'U' query_type
from dual
union all
select '153' query_id, '(020)22214266' query_no, 'U' query_type
from dual) B
where B.QUERY_TYPE = 'U'
and b.query_no = A.TEL_NO(+)
and b.query_no = '(020)22214266';
1. and SUBSTR(B.QUERY_NO, INSTR(B.QUERY_NO, ')') + 1) = A.TEL_NO(+)
2. and b.query_no = A.TEL_NO(+)
------------
不一定呀,不满足条件and b.query_no = A.TEL_NO(+)怎么会显示出来呢
SQL> select b.query_id, B.QUERY_NO, A.TEL_NO
2 from (select '22214266' tel_no
3 from dual
4 union all
5 select '22214266' tel_no from dual) A,
6 (select '152' query_id, '(020)22214266' query_no, 'U' query_type
7 from dual
8 union all
9 select '153' query_id, '(020)22214266' query_no, 'U' query_type
10 from dual) B
11 where B.QUERY_TYPE = 'U'
12 and b.query_no = A.TEL_NO(+)
13 and b.query_no = '(020)22214266';QUERY_ID QUERY_NO TEL_NO
-------- ------------- --------
153 (020)22214266
152 (020)22214266 SQL>
SQL> select '152' query_id, '(020)22214266' query_no, 'U' query_type
2 from dual
3 union all
4 select '153' query_id, '(020)22214266' query_no, 'U' query_type
5 from dual
6 /QUERY_ID QUERY_NO QUERY_TYPE
-------- ------------- ----------
152 (020)22214266 U
153 (020)22214266 U