简体   繁体   English

从一个表到另一表获取列

[英]Get columns from one table to another

So I'll create a combination of all first names and all surnames from a table (Person). 因此,我将创建一个表(人)中所有名字和所有姓氏的组合。

insert into tabell_med_navn 
select f.fornavn, e.etternavn
from person f cross join person e

These combinations should then be added to a table I have made earlier. 然后将这些组合添加到我之前创建的表中。

create table tabell_med_navn (
  id int not null auto_increment,
  fornavn varchar(40) null,
  etternavn varchar(40) null,
  primary key (id)
);

It is when I am trying to send the combination over it fails. 当我尝试通过其发送组合失败时。 Anybody know why it fails? 有人知道为什么失败吗?

List the columns being inserted: 列出要插入的列:

insert into tabell_med_navn (fornavn, etternavn)
    select f.fornavn, e.etternavn
    from person f cross join
         person e;

This will assign a default value to the id column. 这将为id列分配一个默认值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从一个表中获取一列,而从另一表中获取两列 - Get one column from one table with two columns of another table 如何从一个表中获取所有列,而从另一张表中仅获取具有ID的一列? -MySQL - How to get all columns from one table and only one column from another table with ID ? - MySql 如何在 SQLITE 中从一个表中获取所有列并从另一表中获取一列 - How to get all columns from one table and one column from another table in SQLITE 如何将一个列数据从一个表中获取到另一个表中作为PL / SQL中的不同列 - how to get one column data from one table into another table as different columns in PL/SQL 将列从一个表插入到另一个表的过程 - procedure to insert columns from one table to another 将一个表中的列与另一个表进行匹配 - Matching columns from one table with another 将Mysql列从一个表添加到另一个表 - Adding Mysql columns from one table to another 将特定列从一个表复制到另一个 - Copy specific columns from one table to another Select 一个表的所有列和另一个表的一些列 - Select all columns from one table and some from another table 获取具有一列的一个表的所有列,该列必须从与其数据对应的另一个表派生数据 - Get all Columns of One table having one column which has to derive data from another table corresponding to its data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM