实现上面的操作
create table emp(
id int comment '编号',
workno varchar(10) comment '工号',
name varchar(10) comment '姓名',
gender char(1) comment '性别',
age tinyint unsigned comment '年龄',
idcard char(18) comment '身份证号',
workaddress varchar(50) comment '工作地址',
entrydate date comment '入职时间'
)comment '员工表';
insert into emp (id, workno, name, gender, age, idcard, workaddress, entrydate)
values (1, '1', '王政', '男', 19, '1234567890123456x8', '北京','2003-01-02'),
(2, '2', '薇薇', '女', 23, '1234567890123456x8', '广州','2001-01-11'),
(3, '3', '小红', '女', 30, '123456789012345xx8', '上海','2002-02-11'),
(4, '4', '曹操', '男', 29, '123456789012345888', '广西','2002-03-01'),
(5, '5', '刘备', '女', 20, '123456789012345558', '西天','2004-04-01'),
(6, '6', '拉格', '女', 22, '123456789012445678', '上海','2001-05-01'),
(7, '7', '典韦', '男', 20, '123456789012345638', '深圳','2002-06-01'),
(8, '8', '白起', '女', 21, '123456789012345648', '北京','2002-08-01'),
(9, '9', '索隆', '女', 32, '123456789012347678', '广州','2003-09-01'),
(10, '10', '蔡徐坤', '女', 21, '123456789012323678', '西天','2010-01-01'),
(11, '11', '半藏', '男', 24, '123456789012345238', '上海','2005-11-01'),
(12, '12', '小白', '女', 25, '123456789012345618', '北京','2000-01-01'),
(13, '13', '一户', '男', 22, '123456789012345628', '南京','2002-01-01'),
(14, '14', '鸣人', '女', 23, '123456789012375678', '海南','2001-01-01'),
(15, '15', '虞姬', '女', 23, '123456789012375678', '海南','2001-01-01'),
(16, '16', '露琪亚', '女', 28, '123856789012345678', '北京','2001-02-01');
select name,workno,age from emp;
select id, workno, name, gender, age, idcard, workaddress, entrydate from emp;
select * from emp;
这种方法等价于select id, workno, name, gender, age, idcard, workaddress, entrydate from emp;但是在实际开发中最好不要这样,不直观,而且影响效率。
select workaddress as '工作地址' from emp;
select distinct workaddress '工作地址' from emp;