首页 > 解决方案 > 为什么我在对具有相似列名的 2 个表进行内部连接时收到“列名重复”错误?

问题描述

CREATE TABLE student_activestudent AS 
(
   SELECT * 
   FROM
      student
   INNER JOIN
      activestudent ON activestudent.studentnumber=student.studentnumber
);

我期待一个包含 2 列学生编号的表,但我收到了重复错误-> 重复列名称“学生编号”

标签: sql

解决方案


您不能选择具有相同列名称的两个表。

最好的方法是不要选择 *

按列选择,如果列相同,您可以输入 [as]

例子

选择 student.studentnumber 作为 stuNumber,activestudent.studentnumber 作为acttuNumber


推荐阅读