Sql基础

SELECT 列名称 FROM 表名称
SELECT * FROM 表名称
SELECT DISTINCT Company FROM Orders   去重

SELECT 列名称 FROM 表名称 WHERE 列 运算符 值
 = 等于
<> 不等于
> 大于
< 小于
>= 大于等于
<= 小于等于
BETWEEN 在某个范围内
LIKE 搜索某种模式

 

SELECT * FROM Persons WHERE City='Beijing'
SELECT * FROM Persons WHERE FirstName='Thomas' AND LastName='Carter'
SELECT * FROM Persons WHERE FirstName='Thomas' OR LastName='Carter'
SELECT Company, OrderNumber FROM Orders ORDER BY Company

INSERT INTO 表名称 VALUES (值1, 值2,....)
INSERT INTO table_name (列1, 列2,...) VALUES (值1, 值2,....)

UPDATE 表名称 SET 列名称 = 新值 WHERE 列名称 = 某值
UPDATE Person SET FirstName = 'Fred' WHERE LastName = 'Wilson'
UPDATE Person SET Address = 'Zhongshan 23', City = 'Nanjing' WHERE LastName = 'Wilson'

DELETE FROM 表名称 WHERE 列名称 = 值
DELETE FROM Person WHERE LastName = 'Wilson' 
DELETE FROM table_name
 
 
posted @ 2016-12-06 19:27  高中国流  阅读(263)  评论(0编辑  收藏  举报