Mysql 创建表时遇到的问题

Mysql 创建表时遇到的问题,mysql,Mysql,我想创建一个表并用记录填充它。新表应命名为majorlist,并应包括学生ID、学生姓名(名字和姓氏之间用空格连接)、专业和每个学生的年龄(以整年为单位)。标记输出列SID、Name、Major和Age create table majorlist select studentid as 'SID' from students select concat(firstname,' ',lastname) as "name" from students select major as 'maj

我想创建一个表并用记录填充它。新表应命名为majorlist,并应包括学生ID、学生姓名(名字和姓氏之间用空格连接)、专业和每个学生的年龄(以整年为单位)。标记输出列SID、Name、Major和Age

create table majorlist
 select studentid as 'SID' from students
 select concat(firstname,' ',lastname) as "name" from students
 select major as 'major' from students
 select round((datediff(now(),DOB))/365) as "age" from students;

我知道每一个都是单独工作的,但我不知道如何在不出错的情况下将它们集成到一个表中。我试着从每一个选项中删除select stations,但仍然不起作用。

是的,@juergen d的答案很好。您通过获取单个表的值来创建表
students

create table majorlist 
select studentid as 'SID',
       concat(firstname,' ',lastname) as "name", 
       round((datediff(now(),DOB))/365) as "age" 
from students;
然后最好使用一个
select
语句进行抓取。您可以使用如下查询-

 create table majorlist 
   select studentid as 'SID',
   concat(firstname,' ',lastname) as 'name',round((datediff(now(),DOB))/365) as 'age' 
   from students;