执行使用俩个表的select语句

SQL> select*

  2  from product_types;


PRODUCT_TYPE_ID NAME
--------------- ----------
              1 Book
              2 Video
              3 DVD
              4 CD

              5 Magazine


SQL> select *

  2  from products;


PRODUCT_ID PRODUCT_TYPE_ID NAME
---------- --------------- ------------------------------
DESCRIPTION                                             PRICE
-------------------------------------------------- ----------
         1               1 Modern Science

A description of modern science                         19.95


         2               1 Chemistry

Introduction to Chemistry                                  30


         3               2 Supernova

A star explodes                                         25.99


PRODUCT_ID PRODUCT_TYPE_ID NAME
---------- --------------- ------------------------------
DESCRIPTION                                             PRICE
-------------------------------------------------- ----------
         4               2 Tank War

Action movie about a future war                         13.95


         5               2 Z Files

Series on mysterious activities                         49.99


         6               2 2412: The Return

Aliens return                                           14.95


PRODUCT_ID PRODUCT_TYPE_ID NAME
---------- --------------- ------------------------------
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


PRODUCT_ID PRODUCT_TYPE_ID NAME
---------- --------------- ------------------------------
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;


NAME                           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行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值