简体   繁体   English

在两个不同的表中添加相同的值

[英]Add same values in two different tables

I have two tables 'order' & 'new-order', i need to add same values in both these table by using a single line of code. 我有两个表“ order”和“ new-order”,我需要通过使用一行代码在这两个表中添加相同的值。

My code is as follows:- 我的代码如下:

/ To add value in first Table / / 在第一个表中增加价值 /

mysql_query("insert into order (display, project, keyword) values ('$cname','$pro','$kwrd')"); mysql_query(“插入order (显示,项目,关键字)值('$ cname','$ pro','$ kwrd')”);

/ To add same value in second Table / / 在第二个表中添加相同的值 /

mysql_query("insert into neworder (display, project, keyword) values('$cname','$pro','$kwrd')"); mysql_query(“插入新neworder (显示,项目,关键字)值('$ cname','$ pro','$ kwrd')”));

Now can i use some thing like this:- 现在我可以使用这样的东西:

mysql_query("insert into order && neworder (display, project, keyword) values ('$cname','$pro','$kwrd')"); mysql_query(“插入order && neworder (显示,项目,关键字)值('$ cname','$ pro','$ kwrd')”);

and if not then what should be the correct one. 如果没有,那应该是正确的。

You can read more about it from the MySQL Manual . 您可以从MySQL手册中了解更多信息。 In short, you cannot insert into multiple tables at once. 简而言之,您不能一次插入多个表。 This leaves you with three options: 这给您三个选择:

  1. Multiple INSERT statements 多个INSERT语句
  2. Triggers 触发器
  3. Stored Procedures 存储过程

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

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