1

How would I do this (the part in square brackets):

$name = 'Bob';

mysql_query("INSERT INTO table(field1,field2) 
[ select value of field1 from another table ], '$name'");

1 Answer 1

5

The SQL part of it might look like this:

INSERT INTO table1 (field1, field2) SELECT field1, 'Bob' FROM table2 WHERE ...

Dynamically constructing that in PHP is a simple exercise I leave up to the reader :)

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.