加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

新实验四:SQL查询基础练习

(2008-11-12 16:12:44)
标签:

校园生活

教育

分类: 数据库系统原理

1.在产品表(Products)中找出库存大于30的产品的所有信息

SQL语句:select *

         from Products

         where UnitsInStock>30

2.查询顾客表(Customers)中所有不重复的所在城市

SQL语句:select distinct City

         from Customers

3.在订单表(Orders)中找出运费在10到50之间的订单编号、顾客编号和职员编号

SQL语句:select OrderID,CustomerID,EmployeeID,Freight

         from Orders

         where Freight between 10 and 50

4.在顾客表(Customers)中找出所在城市为London的联系人名和公司名

SQL语句:select ContactName,CompanyName,City

         from Customers

         where City='London'

5.在顾客表(Customers)中找出所在城市为London、Madrid、Torino和Paris的顾客编号及电话

SQL语句:select CustomerID,Phone,City

         from Customers

         where City in('London','Madrid','Torino','Paris')

6.在订单表(Orders)中找出国籍不是Brazil、Spain和Mexico的订单编号和订货日期

SQL语句:select OrderID,OrderDate,ShipCountry

         from Orders

         where ShipCountry not in ('Brazil','Spain','Mexico')

7.在产品表(Products)中找出单位数量中有box的产品名和产品编号

SQL语句:select ProductID,ProductName

         from Products

         where QuantityPerUnit like '%box%'

8.在顾客表(Customers)中找出公司名的首字母为F的顾客编号和联系人名

SQL语句:select CustomerID,ContactName

         from Customers

         where CompanyName like 'F%'

9.在顾客表(Customers)中找出公司名的首字母为F,第5位为k的顾客编号和联系人名

SQL语句:select CustomerID,ContactName,CompanyName

         from Customers

         where CompanyName like 'F_ _ _k%'

0

阅读 收藏 喜欢 打印举报/Report
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有