Abby
Abby

Reputation: 61

How to insert multiple results from a query into another table?

my query is below :

$qStuff=mysql_query("SELECT c.field_name,t.category_name,t.category_code, d.domain_name FROM category_fields c, taxonomy_category t, taxonomy_domain d WHERE c.category_id = t.category_id AND t.domain_id = d.domain_id AND c.field_name = '" . mysql_real_escape_string($first_word) . "'");

From the query above,the query will return the result where the input match the field_name in the table.

eg

Field_name : Define (Result from the $qStuff query) (Field_name>Category>Domain) Define>P1>Cognitive Define>C1>Affective

I have to store them in a table so that i know from that table the define has P1 and C1 as category and Cognitive and Affective as domain.How should i do that ?What will the insert query looks like ? Please help ,thanks in advance!!!

Upvotes: 0

Views: 685

Answers (1)

zerkms
zerkms

Reputation: 254926

You don't even need to perform separated SELECT query, because of there is a special construct in mysql for such cases: INSERT ... SELECT

Upvotes: 4

Related Questions