[英]Insert into table with foreign key Mysql
Customer (Customer_id, Customer_Name)
Customer_Phone (Cus_id, Cus_Phone)
I have this two tables and these are connected with a foreign key我有这两个表,它们用外键连接
I want to insert data to both tables can i do that with one sql statement我想向两个表中插入数据我可以用一个 sql 语句来做到这一点
The Customer_id in the Customer table is auto Incremented. Customer 表中的 Customer_id 是自动递增的。
This is a one to many relation这是一对多的关系
i tried INSERT INTO Customer ("Admin","123456")
我尝试INSERT INTO Customer ("Admin","123456")
Please Help thank you请帮忙谢谢
There were two tables, you can insert values to single table at a time.有两个表,您可以一次将值插入单个表。 But you can combine multiple inserts in a sql query.但是您可以在 sql 查询中组合多个插入。
INSERT INTO CUSTOMER VALUES (1,"Customer1"),(2,"Customer2");插入客户价值 (1,"Customer1"),(2,"Customer2"); INSERT INTO CUSTOMER_PHONE VALUES (1,"133443736466"),(1,"6464747373"),(2,"5664747478");插入 CUSTOMER_PHONE 值 (1,"133443736466"),(1,"6464747373"),(2,"5664747478");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.