[摘要]MySQL如何实现单表查询?本篇文章就给大家介绍MySQL单表查询的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。首先我们来创建表、插入数据:# 创建表
mysql> ... MySQL如何实现单表查询?本篇文章就给大家介绍MySQL单表查询的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对你们有所帮助。首先我们来创建表、插入数据: # 创建表
mysql> create table company.employee5(
id int primary key AUTO_INCREMENT not null,
name varchar(30) not null,
sex enum('male','female') default 'male' not null,
hire_date date not null,
post varchar(50) not null,
job_description varchar(100),
salary double(15,2) not null,
office int,
dep_id int
);
# 插入数据
mysql> insert into company.employee5(name,sex,hire_date,post,job_description,salary,office,dep_id) values
('jack','male','20180202','instructor','teach',5000,501,100),
('tom','male','20180203','instructor','teach',5500,501,100),
('robin','male','20180202','instructor','teach',8000,501,100),
('alice','female','20180202','instructor','teach',7200,501,100),
('tianyun','male','20180202','hr','hrcc',600,502,101),
('harry','male','20180202','hr',NULL,6000,502,101),
('emma','female','20180206','sale','salecc',20000,503,102),
('christine','female','20180205','sale','salecc',2200,503,102),
('zhuzhu','male','20180205','sale',NULL,2200,503,102),
('gougou','male','20180205','sale','',2200,503,102);
# 查看表结构
mysql> desc employee5;
+-----------------+-----------------------+------+-----+---------+----------------+
|