简体   繁体   English

如何通过mysql或python将数据插入另一个具有相同id的表中

[英]How to insert data into another table with same id by mysql or python

I have the following table:我有下表:

在此处输入图片说明

I want like this:我想要这样:

在此处输入图片说明

Thanks!谢谢!

I don't recommend this process because it is extremely messy, but if it helps, more power to you, I guess.我不推荐这个过程,因为它非常混乱,但如果它有帮助,我想你会更有力量。 Also, make sure that when you post a question, you include the code that the question is referring to.此外,请确保在发布问题时,包含问题所指的代码。 It helps other users a lot more and makes them much more willing to help!它可以帮助其他用户更多,并使他们更愿意提供帮助!

Because MySQL will not let you put in repeat CHAR or VARCHAR columns, I suggest you either uniquely name the columns based on why they're separated this way, or make unique tables.因为 MySQL 不允许您放入重复的 CHAR 或 VARCHAR 列,我建议您要么根据它们以这种方式分隔的原因来唯一命名这些列,要么制作唯一的表。

Unique Column Names:唯一列名:

CREATE TABLE 'tableName' (
id INT NOT NULL,
time1 TIME NOT NULL,          //Just continue naming your columns in a different way
action1 CHAR(6) NOT NULL, 
station1 VARCHAR NOT NULL,
PRIMARY KEY(primaryKey)       //Use this to uniquely identify you table by a distinct 
);                            //variable (probably id)

To make unique tables, just repeat the table above over and over again with a different Table Name.要制作独特的表格,只需使用不同的表格名称一遍又一遍地重复上面的表格。 To connect all your tables together, use a foreign key.要将所有表连接在一起,请使用外键。 This key's variable needs to have entries that exist in all tables to have all table data connected.该键的变量需要在所有表中都存在条目才能连接所有表数据。 Read more about it here: Foreign Keys and How to Use Them在此处阅读更多相关信息:外键和如何使用它们

Good Luck!祝你好运!

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM