标签:
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
标签:
原文地址:http://www.cnblogs.com/wuxiangli/p/5621818.html