Is it possible to create a table in mySQL from two or more existing tables?
Can I create a table like so:
CREATE T
How about:
CREATE TABLE IF NOT EXISTS USER SELECT * FROM USERNAME, USERAGE WHERE FALSE;
You can furthermore specify any indexes you require in the new table prior to the SELECT
keyword, or rename columns/select some subset as usual on the right of SELECT
:
CREATE TABLE IF NOT EXISTS USER (PRIMARY KEY(UNAME)) SELECT NAME AS UNAME -- etc
If you want to combine all columns of the same name, just use NATURAL JOIN
s in your SELECT
.
See CREATE TABLE ... SELECT for more information.