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

东莞网站建设用哪种好做外文网站

东莞网站建设用哪种好,做外文网站,技能培训机构,个人备案域名购买语法的执行顺序 select 4 字段列表 from 1 表名列表 where 2 条件列表 group by 3 分组前过滤 having 分组后过滤 order by 5 排序字段列表 limit 6 分页参数 聚合函数 count 统计数量 max 最大值 min 最小值 avg 平均 sum 总和 分组查询使…语法的执行顺序   select 4 字段列表   from 1 表名列表   where 2 条件列表   group by 3 分组前过滤   having 分组后过滤   order by 5 排序字段列表   limit 6 分页参数 聚合函数   count 统计数量   max 最大值   min 最小值   avg 平均   sum 总和 分组查询使用例子 1.性别分组统计数量   select gender count*from emp group by gender   2.性别分组 统计平均年龄   select age avg(age) from emp group by gender   3.查询年龄小于45的员工并且按照工作地址分组获取员工数量3的工作地址   首先   按工作地址分组然后获取年龄小于45的员工的地址信息的总数   select workaddresscount*from emp where age45 group by workaddress   再分组完后进行过滤   having count*3 排序查询使用例子 语法   select 字段列表 from 表名 order by 字段1 排序方式1字段2排序方式2   排序方式   1.ASC升序默认   2.DESC降序   例子   1.根据年龄进行排序2.年龄相同再入职日期降序排序   select age from emp order by ageasc,entrydate desc   多字段排序第一个字段相同时再进行第二个字段排序 分页查询   语法   select 字段列表 from 表名 limit 起始索引查询记录数   select * from emp limit 0 10 函数 字符串函数   concats1,s2,s3字符串的拼接   lowerstr 小写 upperstr大写   lpadstr,n,pad   左填充用字符串pad对左边进行填充达到n个字符串长度   rpadstrnpad   右填充   trimstr   去掉字符串头部和尾部的空格   substringstrstartlen   返回字符串str从str位置起的len个长度的字符串   如   int类型不能补0因为是整形但可以补1   数值函数   ceilx 向上取整   floorx 向下取整   modX,Y 返回x/y的模   rand返回0-1内的随机数   roundX,Y四舍五入保留y位小数   日期函数   curdate() 日期   curtime() 时间   now() 现在   yeardate 获取指定date的年份   monthdate 获取指定date的月份   daydate 日期   date-adddateinterval exprtype   返回这个日期加上一个时间间隔后的时间值   datediffdate1date2   返回起始时间date1和结束时间date2之间的天数 流程函数   ifvaluetf   true返回t   false返回f   ifnullvalue1,value2不空返回value1空的话返回value2   case when then   case when [val]then [res1] else [defaulse] End   val为true则返回res1   否则返回default默认值   case [expr] when [val] then [res1] else [default] End   end是结束   当expr的值等于val时返回res1否则返回default   使用例子   select name,(case workaddress when北京 then一线when‘上海’then‘一线’ end)as‘工作地址’   增删改查 添加数据   1.给指定字段添加数据 insert values   insert into 表名(字段1 字段2) values值1值2   2.给全部字段添加数据不写出具体字段名   insert into 表名 values(值1值2)   3.批量添加数据   给特定字段   insert into 表名字段1字段2values(值1值2)值1值2;   给全部字段   insert into 表名 values (值1值2) (值1值2) (值1值2) 更新与删除 修改数据update set   update 表名 set 字段名1值1字段名2值2......[where 条件]   不写条件where的话就是所有都执行   删除数据 delete   delete from 表名 [where 条件]   联合查询(union) union查询就是把多次的查询结果合并起来形成一个新的查询结果   select 字段列表 from 表a   union[all]   select 字段列表 from 表b   分别查询薪资5000年龄50的员工   select *from emp where salary5000   union all   select *from emp where age50   但是结果会有重复的为了去重   可以把all去   报错情况 select *from emp where salary5000   union all   select name from emp where age50   这个会发现报错   因为对于联合查询来说。字段表的列数和字段类型必须保持一致   子查询 子查询   又称为 嵌套查询   标量子查询   查询销售部的所有员工信息   1. select id from emp where name销售部;   第一部查询出销售部id等于4   2.select *from emp where dept_id4;   要两条指令但我们想用一条搞定   select *from emp where dept_idselect id from emp where name销售部   列子查询   常用操作符 in,not in,any,some,all   1   select id from dept where name销售部or name市场部;   查出的id是1和2   然后   select* from emp where dept_id in (1,2)   或者   select* from emp where dept_id in (select id from dept where name销售部or name市场部);   2   查询比财务部的所有人工资都高的员工的 信息   a 查询所有财务部人员的工资   select id from dept where name财务部;   select salary from emp where dept_id3   b查询比财务部所有人工资都高的员工信息   select *from emp where salary all( select salary from emp where dept_id3)   3   查询比研发部其中任意一人工资都高的员工信息   因为是任意一人所以 没有all   行子查询   查询与‘张无忌’薪资以及领导都相同的员工的信息 a.查询张无忌的工资及其领导   select salary,managerid from emp where name张无忌 b. 查询员工   select *from emp where salary12500 and mangerid 1;   或者   select *from emp where salarymanagerid)(12500,1);   再或者   select *from emp where(salary,mangerid)select salary,managerid from emp where name张无忌   表子查询   常用操作符 in   1.查询与‘路’和‘白’薪资以及职位相同的员工   select job,salary from emp where name路or name‘白’   select * from emp where (job,salary) in(select job,salary from emp where name路or name‘白’)   2.查询入职日期是“2006-01-01”之后的员工信息及其部门信息   select * from emp where entrydate2006-01-01   把上面那个作为临时表   select e.*,d.* from(select * from emp where entrydate2006-01-01) e left join dept d on e.dept_idd.id   多表联查 1.查询员工的姓名年龄职位部门信息隐式内连接   表emp dept   连接条件emp.dept_iddept.id   记得消除笛卡尔积   select e.name,e.age,e.job,d.name from emp e, dept d where e.dept_idd.id;   2.查询年龄小于30岁的员工的姓名年龄职位部门信息显示内连接   select e.name,e.age,e.job,d.name from emp e inner join dept d on e.dept_idd.id where e.age30   3.查询拥有员工的部门id和部门名称   求取员工表和部门表之间的交集用内连接   select d.id,d.name from emp e,dept d where e.dept_idd.id   此时会有多个重复的部门因为他是按照员工数量来的   去重复用 distinct   select distinct d.id,d.name from emp e,dept d where e.dept_idd.id   4.查询所有年龄大于40的员工及其归属部门的名称如果员工没有分配部门也要显示出来   要用外连接   select e.*,d.name from emp e left join dept d on e.dept_idd.id where e.age40   5.查询所有员工的工资等级   表:emp salarygrade   连接条件emp.salary salagrade.losal and emp.salarysalagrade.hisal   select e.*,s.grade emp e,salagrade s where e.salarys.losal and e.salary s.hisal   第二种写法:   select e.*,s.grade emp e,salagrade s where e.salary between s.losal and s.hisal   6.查询 研发部 所有员工的信息以及工资等级   涉及到的表emp dept salgrade   连接条件:   emp.salary between s.losal and s.hisal   emp.dept_iddept.id   查询条件 dept.name研发部   select e.*,s.grade from emp e ,dept d,salgrade s where e.dept_idd.id and ( emp.salary between s.losal and s.hisal)and d.name研发部   7.查询研发部员工的平均工资   表 emp dept   select avg(e.salary) from emp e, dept d where e.dept_idd.id and e.name研发部   8.查询工资比‘灭绝’高的员工信息   select * from emp where salary(select salary from emp where name灭绝)   查询灭绝的薪资   select salary from emp where e.name灭绝   9.查询比平均薪资高的员工信息   select avg(salary) from emp   select * from emp where salary(select avg(salary) from emp)   10.查询低于 本部门 平均薪资的员工   a.查询指定部门的平均薪资   select avg(e.salary) from emp e where e.dept_id1   select avg(e.salary) from emp e where e.dept_id2   b.   select *from emp e2 where salary(select avg(e.salary) from emp e where e.dept_ide2.dept_id)   保证平均下来的薪资是同一个部门的   11.查询所有的部门信息并统计部门的员工人数   a.查询信息   select id,name from dept   b.查询指定部门的人数   select count(*) from emp where dept_id1   最终   select d.id ,d.name (select count(*) from emp e where e.dept_idid)人数 from dept d;   12.查询所有学生的选课情况展示出学生的名称学号课程名称   表student ,course,student_course   连接条件student.idstudent_course.studentid,course.idstudent_course.courseid   select s.name ,s.no,c.name from student s,student_course sc,course c where s.idsc.studentid and sc.courseidc.id
http://www.w-s-a.com/news/802701/

相关文章:

  • 销售公司怎么做网站删除wordpress
  • 毕节网站怎么做seohtml代码特效银河系
  • 淄博品质网站建设网站引导页案例
  • 网站建设虚拟空间小豹子韬韬是哪个网站做的
  • 网络司网站如何建立公司网站建议和规则
  • 织梦网站模板后台密码找回企业vi设计公司性价比高
  • php 爬取网站所有链接传奇手游发布网站
  • 免费软文网站wordpress中文名注册
  • 企业网站建设研究目的意义怎样设计一个公司网站
  • 怎么架构网站便民信息发布平台
  • 网站 建设 现状网站推广合同需要缴纳印花税吗
  • 熊猫头表情包制作网站wordpress 缺省目录
  • 网站浏览图片怎么做的群晖wordpress升级5.0
  • 25个优秀个人网站设计模板网站建设定位分析论文
  • 在线网站备案站长seo综合查询工具
  • 网站根 html网站建设行业数据
  • 网站公司做的网站有最字设计说明室内设计
  • 在线网站代码生成我想做个百度网站怎么做
  • 网站的建设费用分为长治市建设厅官方网站
  • 做网站都有哪些费用建设免费手机网站
  • 网站 组成代码做网站图片怎么插
  • 2020中国企业500强榜单南宁seo标准
  • 北美购物网站排名烟台专业的网站建站公司
  • 门户网站设计特点营销策划咨询机构
  • 天津做网站就到徽信xiala5中国营销型网站
  • 外汇网站建设制作深圳三站合一网站建设
  • 深圳坂田网站设计公司有哪些学校网站建设管理办法
  • 太原建设银行网站中山营销型网站设计
  • 广东省建设厅官方网站多少钱江苏省江建集团有限公司建设网站
  • 网站开发主流服装网站开发课程设计