随笔分类 -  mysql 数据操作 单表查询

摘要:1. 分页显示,每页5条 mysql> select * from employee limit 0,5; +----+------------+--------+-----+------------+---------+--------------+------------+--------+-----------+ | id | name | sex | age ... 阅读全文
posted @ 2018-11-01 18:38 minger_lcm 阅读(221) 评论(0) 推荐(0)
摘要:1. 查询各岗位内包含的员工个数小于2的岗位名、岗位内包含员工名字、个数 mysql> select post,group_concat(name),count(id) from employee group by post; +-----------+-------------------------------------------------+-----------+ | pos... 阅读全文
posted @ 2018-11-01 16:22 minger_lcm 阅读(176) 评论(0) 推荐(0)
摘要:1. 查询岗位名以及岗位包含的所有员工名字 mysql> select post,group_concat(name) from employee group by post; +-----------+-------------------------------------------------+ | post | group_concat(name) ... 阅读全文
posted @ 2018-10-30 19:02 minger_lcm 阅读(155) 评论(0) 推荐(0)
摘要:有个需求用concat以这种格式打印查询 mysql中 有个concat_ws 可以简单实现 阅读全文
posted @ 2018-10-30 00:44 minger_lcm 阅读(248) 评论(0) 推荐(0)
摘要:查出所有员工的名字,薪资,格式为 , mysql> select concat('') as name_info , concat('') as salary_info from employee; +---------------------+---------------------+ | name_info | salary_info |... 阅读全文
posted @ 2018-10-30 00:44 minger_lcm 阅读(269) 评论(0) 推荐(0)
摘要:加上性别 别名 阅读全文
posted @ 2018-10-30 00:43 minger_lcm 阅读(690) 评论(0) 推荐(0)
摘要:查出来的结果 这是一张虚拟表 因为查出来结果 标注红色的 salary*12 不太直观 利用另外一种方式查表 as 给字段起别名 select 字段 as 别名 from 表名 不加as也可以 默认后面就是别名 阅读全文
posted @ 2018-10-30 00:42 minger_lcm 阅读(1513) 评论(0) 推荐(0)
摘要:创建数据库company use company; 阅读全文
posted @ 2018-10-30 00:41 minger_lcm 阅读(733) 评论(0) 推荐(0)