If you want to create a table that has the same structure as the result set of a query, run:
mydb> CREATE TABLE foobar AS SELECT ...;