码迷,mamicode.com
首页 > 数据库 > 详细

SQL复习

时间:2016-06-27 23:05:08      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

1、select

SELECT LastName,FirstName FROM Persons

SELECT * FROM Persons

2、distinct

SELECT DISTINCT Company FROM Orders

3、WHERE

SELECT * FROM Persons WHERE city=‘beijing‘

4、AND&OR运算符

SELECT * FROM Persons WHERE FirstName=‘tomas‘ AND LastName=‘carp‘

SELECT * FROM Persons WHERE FirstName=‘tomas‘ OR LastName=‘carp‘

5、ORDER BY

默认是升序,可以自己添加ASC 和DESC

SELECT Company,OrderNumber FROM Orders ORDER BY Company,OrderNumber  //首先按照Company升序排列,在Company相同的时候按照OrderNumber关键字升序排列

SELECT Company,OrderNumber FROM Orders ORDER BY Company DESC,OrderNumber ASC  //首先按照Company降序排列,在Company相同的时候按照OrderNumber关键字升序排列

6、insert

插入新的行   INSERT INTO Person VALUES(‘gate‘,‘bill‘,‘xuanwumen 10‘,‘beijing‘)

插入指定列中的数据  INSERT INTO Person(LastName,Address) VALUES(‘wilson‘,‘champli stree‘)

7、update

改变表中的元素值

update Person SET FirstName=‘xiangli‘ WHERE LastName=‘wilson‘

修改一行中的多个列

update Person SET City=‘anhui‘,Address=‘chinal addre‘ WHERE LastName=‘wilson‘

8、delete

删除表中的行

DELETE FROM Person  WHERE LastName=‘wilson‘

删除所有行

DELETE * FROM Person

SQL复习

标签:

原文地址:http://www.cnblogs.com/wuxiangli/p/5621818.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!