当前位置: 首页 > news >正文

除了亚马逊还有啥网站做海淘西安做网站公司

除了亚马逊还有啥网站做海淘,西安做网站公司,网上做宣传的网站,建筑公司网站大全1.基本查询 //查询所有内容 select * from 表名;//查询指定字段 select 字段1,字段2,字段3.....from 表名;//查询时给字段起别名 select 字段1 as 别名1 , 字段2 as 别名2 ... from 表名;//去重查询 select distinct 字段列表 from 表名; …

1.基本查询

//查询所有内容
select * from  表名;//查询指定字段
select 字段1,字段2,字段3.....from 表名;//查询时给字段起别名
select 字段1 as '别名1' , 字段2 as '别名2' ... from 表名;//去重查询
select distinct 字段列表 from 表名;

2.条件查询

//语法
select 字段列表 from 1 表名 where 条件列表 ;//算数运算
mysql> select 5, 5+3, 5-3, 5*3, 5/3, 5.2/3, 5%3, 3%5, 50%30 from dual;
+---+-----+-----+-----+--------+---------+------+------+-------+
| 5 | 5+3 | 5-3 | 5*3 | 5/3 | 5.2/3 | 5%3 | 3%5 | 50%30 |
+---+-----+-----+-----+--------+---------+------+------+-------+
| 5 | 8 | 2 | 15 | 1.6667 | 1.73333 | 2 | 3 | 20 |
+---+-----+-----+-----+--------+---------+------+------+-------+
//dual表是一个虚拟表,用于测试或者在没有真实表的情况下执行一些查询操作,可以省略from dual//省略from dual表字句,查看日期时间
mysql> select now(); 
+---------------------+
| now() |
+---------------------+
| 2023-08-03 14:24:59 |
+---------------------+
1 row in set (0.00 sec)//字符串123会转为数值123
mysql> select "123"+80; 
+----------+
| "123"+80 |
+----------+
| 203 |
+----------+
1 row in set (0.00 sec)//非数值字符串进行数值运算会转为0
mysql> select "china"+80; 
+------------+
| "china"+80 |
+------------+
| 80 |
+------------+
1 row in set, 1 warning (0.00 sec)//注意这里是字符串null
mysql> select "NULL"+100;
+------------+
| "NULL"+100 |
+------------+
| 100 |
+------------+
1 row in set, 1 warning (0.00 sec)//这才是NULL
mysql> select NULL+100; 
+----------+
| NULL+100 |
+----------+
| NULL |
+----------+
1 row in set (0.00 sec)# 查询总分大于200的学生信息
mysql> select distinct name "姓名" , chinese+math+english "总分" from student3
where (chinese+math+english)>200;# 查询男生的信息
mysql> select * from student3 where gender="男";# 查询英语成绩在80到90之间的学生信息
mysql> select * from student3 where english>80 and english<90 ;
mysql> select * from student3 where english between 80 and 90 ;# 查询英语成绩不在80到90之间的学生信息
mysql> select * from student3 where not(english>80 and english<90) ;# 查询数学分数为85,90,的学生信息
mysql> select * from student3 where math=85 or math=90 ;
mysql> select * from student3 where math in (85,90) ;# 查询数学分数不为85,90的学生信息
mysql> select * from student3 where !(math=85 or math=90) ;# 查询所有姓李的学生语文成绩
mysql> select name ,gender, chinese from student3 where name like "李%" ;# 查询姓名为两个字的信息
mysql> select * from student3 where name like "__" ; # 两个_# 插入新数据
mysql> insert into student3(id,name,gender) values (9,'周星星','男');# 查询语文没有考试的学生信息
mysql> select * from student3 where chinese is NULL;
mysql> select * from student3 where chinese<=> NULL;# <=>安全等于,作用
# 可作为普通运算符的=
# 或等价于is NULL
# 正则表达式作为条件
//匹配以数字 9 开头的字符串。
mysql> select * from student3 where math regexp "^9"; # 关键字regexp

3.聚合函数

count(*):所有行进行统计,包括NULL行
count(1):所有行进行统计,包括NULL行
count(某字段):对某字段中非Null进行统计

4.分组查询

//语法
select 字段,聚合函数 from 表名 [ where 条件 ] group by 字段  [ having 分组后过滤条件 ];# 按照班级分组:
mysql> select class_id as '班级编号', round(avg(score),2) as '平均成绩' from
transcript group by class_id;
# 查询平均分在90分及以上的班级
mysql> select class_id as "班级", avg(score) as "平均分" from transcript group by
class_id having avg(score)>90;# 查询每个班级的成绩平均分(不统计成绩在85分以下的学生且过滤掉平均分在90分以下的班级),以便比较不
同班级的成绩
mysql> select class_id as "班级", avg(score) as "平均分" from transcript where
score>85 group by class_id having avg(score)>90;where与having区别
# 执行时机不同:where是分组之前进行过滤,不满足where条件,不参与分组;而having是分组之后对结果进
行过滤。
# 判断条件不同:where不能对聚合函数进行判断,而having可以。

 5.排序查询

order by 字段1 asc/desc, 字段2 asc/desc.....mysql> select * from student3 order by math ;
mysql> select * from student3 order by math desc;# 中文排序,由于使用字符编码不同会出现问题,如按性别升序则女在前男在后了:
mysql> select * from student3 order by gender asc;
mysql> show variables like 'character_set%'; # 查看当前使用的编码# 使用CONVERT函数按照指定编码排序
mysql> select * from student3 order by convert(gender using gbk) asc;
mysql> select * from student3 order by convert(name using gbk) asc;# 分组排序:先按性别排序,组内部按语文成绩降序排列
mysql> select * from student3 order by convert(gender using gbk) asc,chinese
desc;

 6.分页查询

mysql> select * from student3;mysql> select * from student3 limit 2,3; # 查看第2条开始的记录显示3条(包含第2条)mysql> select * from student3 limit 3; # 查看3条记录mysql> select * from student3 limit 3 offset 2; # 查看第2条开始的3条记录,同limit
2,3

 

http://www.khdw.cn/news/35295.html

相关文章:

  • 默认网站预览能能显示建设中湖南网络推广服务
  • 荔湾区网站设计360搜索引擎下载
  • 百度网站排名优化工具网络推广公司哪家做得好
  • 网站建设推广新闻厦门网站的关键词自动排名
  • 网站 设置特殊的字体郑州seo
  • 织梦网站管理后台系统上面的织梦链接怎么样去掉网络优化器免费
  • 专业做网站 优帮云第一接单网app地推和拉新
  • 做网站1天转多钱免费推广渠道有哪些
  • 广州市红十字会医院网站建设项目短视频营销优势
  • 网站如何进行优化2022最近热点事件及评述
  • 烟台专业的做网站公司深圳招聘网络推广
  • 改变网站字体最火网站排名
  • 做美食网站的需求分析关键词优化的技巧
  • 国家信用信息系统年报重庆seo全面优化
  • 做外贸在哪个网站线上营销手段有哪些
  • 深圳台历制作中国seo关键词优化工具
  • 企业营销策划书模板seo外贸网站制作
  • 做网站怎么选取关键词seo推广是什么
  • 哪个网站建设服务器是在国外的外贸建站公司
  • 做网站项目实例看广告得收益的app
  • 网站风格分析淘宝推广哪种方式最好
  • 自己电脑上做网站怎么使用源码已备案域名购买平台
  • 深圳网站建设大公司好合肥网站优化seo
  • 南通江苏网站建设浏览器大全网站
  • 毕节公司做网站曹操论坛seo
  • 苏州网站优化维护友情链接如何添加
  • 新任上海市领导调整公示seo岗位工资
  • 建设一个大型网站大概费用百度收录好的免费网站
  • 做设计最好的参考网站长春关键词优化平台
  • 杭州网站建设求职简历潍坊关键词优化平台