boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - SQL help.
相关主题
问一个SQL Server的问题
抱怨一下 数据库 里头的一些不严谨。
请教一个求职面试题:如何写一个SQL query求表中对角线的和
urgent help! insert value into table
初级问题
如何用SQL语句判断一个TABLE是否存在?
Help on Sql server huge table performance
How to replace 0 with empty?
MS T-SQL 问题
请教2个sql query 问题
相关话题的讨论汇总
话题: ford话题: sql话题: gm话题: number话题: insert
进入Database版参与讨论
1 (共1页)
h****r
发帖数: 2056
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;
D****N
发帖数: 430
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:

h****r
发帖数: 2056
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

h****r
发帖数: 2056
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".
s********e
发帖数: 62
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".

1 (共1页)
进入Database版参与讨论
相关主题
请教2个sql query 问题
SQL问题请教: add one more column
请教一个SQL的问题
SQL find distinct values in large table
error of executing SQL query of string concatenation (转载
SQL Server stupid questions
SQL Server Trigger on System Base Table or Catalog View
SQL add some columns into a table from another table (转载
怎么去除duplicates
A weird error
相关话题的讨论汇总
话题: ford话题: sql话题: gm话题: number话题: insert