数据库_02_查询

  1. select name from test2;
  2. select name,id from test2;
  3. select * from test2;
  4. select 所有列名 from test2
  5. select distinct age from test2;
  6. select distinct age,name from test2;
  7. select name from test2 limit 5; 显示检索结果的前5行
  8. select name from test2 limit 5,5 显示从第6行开始的5行
  9. select name from test2 order by name;
  10. select name from test2 order by name desc;
  11. select name from test2 order by age,name;
  12. select name from test2 order by age asc,name desc;
  13. select age from test2 order by age desc limit 1;
  14. select name,id from test2 where age=18;
  15. select name,age from test2 where age<18;
    where子句的操作符:
    =. > , >= , < , <= , <> , != , between …and…
    and ,or ,not, in, not in
  16. select name from test2 where age is null;
  17. select concat(age,name) as na from test2;
  18. select concat(age,’(’,name,’)’) as an from test2;
  19. select concat(age,’(’,trim(name),’)’) as an from test2;
  20. select name,id*age as test from test2;
  21. select trim(’ abc’)
  22. select 3*5
  23. select now() ;
  24. select version()
  25. select max(age) from test2; 忽略列值为null的行
  26. select min(age) from test2; 忽略列值为null的行
  27. select upper(name) from test2;
  28. select name,upper(name) from test2;
  29. select name,datetime_test from test2 where date(datetime_test)=‘1999-10-10’;
  30. select name,datetime_test from test2 where time(datetime_test)=‘23:23:23’;
  31. select name,datetime_test from test2 where year(datetime_test)=‘1990’;
  32. select name,datetime_test from test2 where year(datetime_test)=‘1990’
    and month(datetime_test)=‘12’;
  33. select avg(age) from test2; 忽略列值为null的行
  34. select sum(avg) from test2; 忽略列值为null的行
  35. select count(age) from test2; 忽略null值
  36. select count(*) from test2; 不忽略null值
  37. select age,count(*) from test2 group by age ;
  38. select age,count() from test2 group by age having count()>1;
  39. select age,count() from test2 where age>18 group by age having count()>1;
  40. select – from – where – group by – having – order by – limit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值