SQL> select*
--------------- ----------
1 Book
2 Video
3 DVD
4 CD
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
1 1 Modern Science
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
4 2 Tank War
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
7 3 Space Force 9
Adventures of heroes 13.49
8 3 From Another Planet
Alien from another planet lands on Earth 12.99
9 4 Classical Music
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
10 4 Pop 3
The best popular music 15.99
11 4 Creative Yell
Debut album 14.99
12 My Front Line
Their greatest hits 13.49
*************************************************************************
获得产品#3的名称及其产品类型的名称:
SQL> select products.name,product_types.name
2 from products,product_types
3 where products.product_type_id=product_types.product_type_id
4 and products.product_id=3;
NAME NAME
------------------------------ ----------
Supernova Video
*************************************************************************
查询所有产品的名称和产品类型名并排名,注意上面输出没有名为my front line产品,这个产
品的的product_type_id是null,由于这一点,输出结果没有这一行。以后将介绍如何包含这一
行
SQL> select products.name,product_types.name
2 from products,product_types
3 where products.product_type_id=product_types.product_type_id
------------------------------ ----------
2412: The Return Video
Chemistry Book
Classical Music CD
Creative Yell CD
From Another Planet DVD
Modern Science Book
Pop 3 CD
Space Force 9 DVD
Supernova Video
Tank War Video
Z Files Video
已选择11行。
2 from product_types;
--------------- ----------
1 Book
2 Video
3 DVD
4 CD
5 Magazine
2 from products;
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
1 1 Modern Science
A description of modern science 19.95
Introduction to Chemistry 30
A star explodes 25.99
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
4 2 Tank War
Action movie about a future war 13.95
Series on mysterious activities 49.99
Aliens return 14.95
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
7 3 Space Force 9
Adventures of heroes 13.49
8 3 From Another Planet
Alien from another planet lands on Earth 12.99
9 4 Classical Music
The best classical music 10.99
---------- --------------- ------------------------------
DESCRIPTION PRICE
-------------------------------------------------- ----------
10 4 Pop 3
The best popular music 15.99
11 4 Creative Yell
Debut album 14.99
12 My Front Line
Their greatest hits 13.49
*************************************************************************
获得产品#3的名称及其产品类型的名称:
SQL> select products.name,product_types.name
2 from products,product_types
3 where products.product_type_id=product_types.product_type_id
4 and products.product_id=3;
NAME NAME
------------------------------ ----------
Supernova Video
*************************************************************************
查询所有产品的名称和产品类型名并排名,注意上面输出没有名为my front line产品,这个产
品的的product_type_id是null,由于这一点,输出结果没有这一行。以后将介绍如何包含这一
行
SQL> select products.name,product_types.name
2 from products,product_types
3 where products.product_type_id=product_types.product_type_id
4 order by products.name;
------------------------------ ----------
2412: The Return Video
Chemistry Book
Classical Music CD
Creative Yell CD
From Another Planet DVD
Modern Science Book
Pop 3 CD
Space Force 9 DVD
Supernova Video
Tank War Video
Z Files Video
已选择11行。