插入数据
insert into persons values('','','','')
insert into persons (字段,字段,字段) values(value,value,value)
修改数据
update 表名 set 字段=value where 字段=值
删除数据
delete from 表名 where 字段=值
查询语句
- 查询
select * from 表名 where 字段=值
- top
select top 2 * from 表名
查询前俩条数据 - where 条件
- like 模糊查询
select * from 表名 where 字段 like '%n'
- in
select * from tb_name where 字段 in (value,value)
- between
select * from tb_name where 字段 between (value,value)
- like 模糊查询
- order by
select * from tb_name order by 字段 desc
desc asc
多表查询
select a.字段,b.字段 from tb_namea as a,tb_nameb as b where a.id=b.id
SELECT Persons.LastName, Persons.FirstName, Orders.OrderNo FROM Persons INNER JOIN Orders ON Persons.Id_P = Orders.Id_P
- union合并俩个查询结果
SELECT E_Name FROM Employees_China UNION SELECT E_Name FROM Employees_USA;
关键字
- primary key 主键
- auto_increment 自增