Kumar
Kumar

Reputation: 21

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.

My code is as follows:-

/To add value in first Table/

mysql_query("insert into order (display, project, keyword) values ('$cname','$pro','$kwrd')");

/To add same value in second Table/

mysql_query("insert intoneworder(display, project, keyword) values('$cname','$pro','$kwrd')");

Now can i use some thing like this:-

mysql_query("insert into order && neworder (display, project, keyword) values ('$cname','$pro','$kwrd')");

and if not then what should be the correct one.

Upvotes: 1

Views: 47

Answers (1)

Karthik Surianarayanan
Karthik Surianarayanan

Reputation: 626

You can read more about it from the MySQL Manual. In short, you cannot insert into multiple tables at once. This leaves you with three options:

  1. Multiple INSERT statements
  2. Triggers
  3. Stored Procedures

Upvotes: 2

Related Questions