MySQL insert query results into new table

Is it possible to create a new table from the results of a query? I have a query that is getting results from 3 tables and I would like the results inserted into one new table.

You could run two separate queries - one that creates and another that inserts.

Should be straight forward unless I’m missing something (I am no expert :slight_smile: )

That depends on the database you’re using.

Access, as an example, you could do something like

SELECT * INTO NewTable
FROM clients;

But most of the time, you’ll need to do two queries or a stored procedure

The database is MySQL. What would be the best way to get the results of a query and create a new table out of them? I could create the new database structure manually and import each column as a csv file but that’s pretty labor intensive.

Also - I notice that PHPmyAdmin allows an entire table to be exported as SQL. Is there a tool or method for exporting query results as SQL?

[quote=“DirtyDog, post:4, topic:110444, full:true”]
The database is MySQL. [/quote]

in that case, put this line in front of your SELECT statement –

CREATE TABLE foobar
1 Like

Thanks!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.