avatar
h*r
1
I have some thing confused here,
I created two tables:
create table ford (yr NUMBER, mdl VARCHAR2(15));
create table gm (yr NUMBER, mdl VARCHAR(15));
then insert several values into tables,
insert into gm values( 1999, 'grand am');
insert into gm values( 2000, 'GMC');
insert into ford values (2000, 'mustang');
insert into ford values (1999, 'escort');
then I do:

select * from ford, gm;
the output is correct although duplicated,
then I do:

delete ford;
avatar
D*N
2
When you select * from ford,gm the default join is inner join,
meaning nothing will be selected if you don't have matching
rows from ford to gm. In the first case ford is already deleted
so the inner join won't return anything.
The second case you have YR in both tables so it has to be
prefixed, like, select ford.YR from ford,gm...
But your table structures are duplicated such that a join
between these two tables don't necessarily mean anything.
Try putting all the YR and MDL records in the same

【在 h****r 的大作中提到】
: I have some thing confused here,
: I created two tables:
: create table ford (yr NUMBER, mdl VARCHAR2(15));
: create table gm (yr NUMBER, mdl VARCHAR(15));
: then insert several values into tables,
: insert into gm values( 1999, 'grand am');
: insert into gm values( 2000, 'GMC');
: insert into ford values (2000, 'mustang');
: insert into ford values (1999, 'escort');
: then I do:

avatar
h*r
3
Thanks a lot for your point.
BTW, I have another funny question, say I have several
tables and
they include a same coloum name and I want to use the column
name
to choose some records from different tables and remove them
at
once by a nested SQL sentence, how can I do it?
for example,
table A defines as (mId Number, mName Varchar2(10));
A has records:
mId mName
-------------
101, 'Tom'
102, 'Henry'
112, 'Joe'
table B defines as (mId Number, mTitle Va

【在 D****N 的大作中提到】
: When you select * from ford,gm the default join is inner join,
: meaning nothing will be selected if you don't have matching
: rows from ford to gm. In the first case ford is already deleted
: so the inner join won't return anything.
: The second case you have YR in both tables so it has to be
: prefixed, like, select ford.YR from ford,gm...
: But your table structures are duplicated such that a join
: between these two tables don't necessarily mean anything.
: Try putting all the YR and MDL records in the same

avatar
h*r
4
Comments:
for a common situation, the number of table may not be only
three,
and it could be picked up from the set got by using SQL
sentence:
"select * from tab".
avatar
s*e
5
DELETE FROM (select * from tab)
WHERE mld ....;

【在 h****r 的大作中提到】
: Comments:
: for a common situation, the number of table may not be only
: three,
: and it could be picked up from the set got by using SQL
: sentence:
: "select * from tab".

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。