Soop
Soop

Reputation: 417

Creating a table from a query in MySQL/PHP

I'm not sure this is possible, but the code I tried using first is:

mysql_query ("CREATE TABLE My_table as ( SELECT * FROM CPE LEFT JOIN Greenwich_j20 ON CPE.cust_index = Greenwich_j20.cust_index LEFT JOIN Liverpool_j20 ON CPE.cust_index = Liverpool_j20.cust_index)")
 or die ("this certainly didn't work\n");

The query itself works fine, and the syntax for the table works fine, but the combination is what it really doesn't like. Does it have a problem creating a table from a left join query?

Upvotes: 1

Views: 431

Answers (1)

Shakti Singh
Shakti Singh

Reputation: 86476

If there is any auto increment column in your existing tables that will be not remain auto_increment in the table to be created.

You could try by selecting columns instead of * there should be an error of column Ambiguous.

Upvotes: 2

Related Questions