mysql> create view v_w_d as
-> select id,name,d_name,score
-> from tb_worker left join tb_department
-> on d_id=der_id;
然后得到下面这个表
mysql> select*from v_w_d;
+----+------+--------+-------+
| id | name | d_name | score |
+----+------+--------+-------+
| 1 | 小赵 | 技术部 | 9.7 |
| 2 | 小钱 | 人事部 | 9.6 |
| 3 | 小孙 | 财务部 | 9.1 |
| 4 | 小李 | 销售部 | 9.2 |
| 5 | 小周 | 人事部 | 9.0 |
| 6 | 小吴 | 财务部 | 9.3 |
| 7 | 小张 | 技术部 | 9.7 |
+----+------+--------+-------+
然后我想自定义一下名称,就报错了
mysql> create view vwd(员工编号,姓名,部门名称,绩效评分)as
-> select id,name,d_name,score from v_w_d;
ERROR 1353 (HY000): In definition of view, derived table or common table expression, SELECT list and column names list have different column counts
为什么啊!
MySQL自定义列名称的问题
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-