全部博文(136)
分类: Oracle
2008-06-05 14:35:53
select * from test_yct where id_new in( select id_new from test_yct_new
); |
SQL> desc
test_yct
名称 是否为空? 类型 ----------------------------------------- -------- ------------- ID VARCHAR2(13) NAME VARCHAR2(20) ID_NEW VARCHAR2(10) SQL> desc
test_yct_new
名称 是否为空? 类型 ----------------------------------------- -------- ------------ ID_NEW VARCHAR2(10) NAME
VARCHAR2(20)
SQL> select * from test_yct;
ID NAME ID_NEW
------------- -------------------- ------ 1 yuechaotian1 01 2 yuechaotian2 02 3 yuechaotian3 03 4 yuechaotian4 04 5 yuechaotian5 05 6 yuechaotian6 06 7 yuechaotian7 07 8 yuechaotian8 08 9 yuechaotian9 09 10 yuechaotian10 10 已选择10行。
SQL> select * from test_yct_new;
ID_NEW NAME ---------- -------------------- 04 yuechaotian1 05 yuechaotian2 06 yuechaotian3 07 yuechaotian4 |
SQL> select * from test_yct where id_new in( select id_new
from test_yct_new );
ID NAME ID_NEW ------------- -------------------- ---------- 4 yuechaotian4 04 5 yuechaotian5 05 6 yuechaotian6 06 7 yuechaotian7 07 |
SQL> alter table test_yct_new drop column
id_new;
表已更改。
SQL> desc
test_yct_new
名称 是否为空? 类型 ----------------------------------------- -------- ------------ NAME VARCHAR2(20) SQL> select * from test_yct where id_new in( select
id_new from test_yct_new );
ID NAME ID_NEW
------------- -------------------- ---------- 1 yuechaotian1 01 2 yuechaotian2 02 3 yuechaotian3 03 4 yuechaotian4 04 5 yuechaotian5 05 6 yuechaotian6 06 7 yuechaotian7 07 8 yuechaotian8 08 9 yuechaotian9 09 10 yuechaotian10 10 已选择10行。 |
SQL> select * from test_yct where id_new in( select
test_yct.id_new from test_yct_new );
ID NAME ID_NEW
------------- -------------------- ---------- 1 yuechaotian1 01 2 yuechaotian2 02 3 yuechaotian3 03 4 yuechaotian4 04 5 yuechaotian5 05 6 yuechaotian6 06 7 yuechaotian7 07 8 yuechaotian8 08 9 yuechaotian9 09 10 yuechaotian10 10 已选择10行。 |
ORA-00904: "ID_NEW": 无效的标识符 |
SQL> select * from test_yct where id_new in( select id from test_yct_new
);
ID NAME ID_NEW
------------- -------------------- ---------- 10 yuechaotian10 10 SQL> select * from test_yct where id_new in( select test_yct.id from
test_yct_new );
ID NAME ID_NEW ------------- -------------------- ---------- 10 yuechaotian10 10 |