- select name from test2;
- select name,id from test2;
- select * from test2;
- select 所有列名 from test2
- select distinct age from test2;
- select distinct age,name from test2;
- select name from test2 limit 5; 显示检索结果的前5行
- select name from test2 limit 5,5 显示从第6行开始的5行
- select name from test2 order by name;
- select name from test2 order by name desc;
- select name from test2 order by age,name;
- select name from test2 order by age asc,name desc;
- select age from test2 order by age desc limit 1;
- select name,id from test2 where age=18;
- select name,age from test2 where age<18;
where子句的操作符:
=. > , >= , < , <= , <> , != , between …and…
and ,or ,not, in, not in - select name from test2 where age is null;
- select concat(age,name) as na from test2;
- select concat(age,’(’,name,’)’) as an from test2;
- select concat(age,’(’,trim(name),’)’) as an from test2;
- select name,id*age as test from test2;
- select trim(’ abc’)
- select 3*5
- select now() ;
- select version()
- select max(age) from test2; 忽略列值为null的行
- select min(age) from test2; 忽略列值为null的行
- select upper(name) from test2;
- select name,upper(name) from test2;
- select name,datetime_test from test2 where date(datetime_test)=‘1999-10-10’;
- select name,datetime_test from test2 where time(datetime_test)=‘23:23:23’;
- select name,datetime_test from test2 where year(datetime_test)=‘1990’;
- select name,datetime_test from test2 where year(datetime_test)=‘1990’
and month(datetime_test)=‘12’; - select avg(age) from test2; 忽略列值为null的行
- select sum(avg) from test2; 忽略列值为null的行
- select count(age) from test2; 忽略null值
- select count(*) from test2; 不忽略null值
- select age,count(*) from test2 group by age ;
- select age,count() from test2 group by age having count()>1;
- select age,count() from test2 where age>18 group by age having count()>1;
- select – from – where – group by – having – order by – limit
数据库_02_查询
最新推荐文章于 2024-08-17 12:29:37 发布