1

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.

1
  • Triggers The better option Commented Feb 7, 2014 at 5:56

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.