Home > Database > Mysql Tutorial > body text

基础SQL语句

WBOY
Release: 2016-06-07 17:40:48
Original
1245 people have browsed it

增:insert into T_1(Name,Age) values (李小争23); Values 中顺序要和表名中的顺序一致 查:select Name,Id from T1; Select * from T1;//查询出所有字段 select * from T_Student where Age30 删:delete from T_Student where 从T_Student中删除Name

增:insert into  T_1(Name,Age) values (’李小争’23);

Values 中顺序要和表名中的顺序一致

 

查:select Name,Id from T1;

Select * from T1;//查询出所有字段

select * from T_Student where Age

 

删:delete from T_Student where

从T_Student中删除Name字段等于lxz的数据

Delete from T_Student

删除T_Student中的所有数据

 

Delete from T_Student where Age>100 or Name=’lxz’   或者

Delete from T_Student where Age>100 and Height>150   并且

 

 

更新:update T_Student set Age=Age+1

 

update T_Student set Height=180

 

update T_Student set Love='散步' where Age>100

 

select Name as 姓名, Age as 年龄 from T_Student

select MAX(age) from T_Student  查询最大年龄

select MAX(age),MIN(age) from T_Student

 

select MAX(age) as 最大年龄,MIN(age) as 最小年龄,AVG(age) as 平均年龄 from T_Student

select MAX(age) as 最大年龄,MIN(age) as 最小年龄,AVG(age) as 平均年龄,COUNT(*) as 总行数  from T_Student

 

select * from T_Student where Name like 'y%'

查询以y开头后面有若干个字符。。。

 

select * from T_Student where Name like '%a%'

查询含有a

 

 

select * from T_Student order by Age    按照年龄升序排列

select * from T_Student order by Age Desc  按照年龄升序排列

 

select * from T_Student where Name like 'y%' order by Age 

 

,免备案空间,香港虚拟主机,香港服务器租用
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template