Chinaunix首页 | 论坛 | 博客
  • 博客访问: 927772
  • 博文数量: 358
  • 博客积分: 8185
  • 博客等级: 中将
  • 技术积分: 3751
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-15 16:27
个人简介

The views and opinions expressed all for my own,only for study and test, not reflect the views of Any Company and its affiliates.

文章分类

全部博文(358)

文章存档

2012年(8)

2011年(18)

2010年(50)

2009年(218)

2008年(64)

我的朋友

分类: Oracle

2009-07-06 22:21:19

標準:
■SQL:2006 Syntax:
  SELECT table1.column, table2.column
   FROM table1
   [NATURAL JOIN table2] |
   [JOIN table2 USING (column_name)] |
   [JOIN table2 ON (table1.column_name = table2.column_name)] |
   [LEFT | RIGHT | FULL OUTER JOIN table2
   ON (table1.column_name = table2.column_name)] |
   [CROSS JOIN table2];
■Oracle Proprietary Syntax:
    SELECT table1.column, table2.column
    FROM table1, table2
    [WHERE (table1.column_name = table2.column_name)] |
    [WHERE (table1.column_name(+)= table2.column_name)] |
    [WHERE (table1.column_name)= table2.column_name) (+)] ;
・Natrual Join:(same name& same data types)
   NATURAAL JOIN
   USING  (①Do not qualify a column that is used in the Using clause
      ②if the same column is used elsewhere in SQL statement do not alias it)
   ON    (Additional Join Conditions(Use the AND clause or the WHERE clause to               apply aditional conditions)
     eg:
  ・select d.department_name from departments d
join locations l on (l.LOCATION_ID=d.LOCATION_ID)
where d.department_name like 'P%'
   ・select d.department_name from departments d
join locations l on
(l.LOCATION_ID=d.LOCATION_ID and d.department_name like 'P%')
・Nonequijoins
    SELECT table1.column, table2.column
FROM table1
[JOIN table2 ON (table1.column_name < table2.column_name)]|
[JOIN table2 ON (table1.column_name > table2.column_name)]|
[JOIN table2 ON (table1.column_name <= table2.column_name)]|
[JOIN table2 ON (table1.column_name >= table2.column_name)]|
[JOIN table2 ON (table1.column BETWEEN table2.col1 AND table2.col2)]|
・Outer joins:
   LEFT OUTER JOIN
   RIGHT OUTER JOIN
   FULL OUTER JOIN
Cartesian product 笛卡尔积
  A join condition is omitted
   A join condition is invalid
   All rows in the first table are joined to all rows in the second table
  ○the CROSS JOIN clause produces the cross -product of two tables;This is also     called a Cartesian product between the two tables;
    ○ SELECT table1.column, table2.column
  FROM table1
CROSS JOIN table2;

阅读(778) | 评论(0) | 转发(0) |
0

上一篇:Functions

下一篇:Subqueries

给主人留下些什么吧!~~