Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATE TABLE newtable SELECT ... FROM oldtable ?

Status
Not open for further replies.

sbayeta

Programmer
Apr 4, 2003
13
0
0
AR
Hi,
I have a table with 3 DOUBLE fields: "x", "y" and "f".
From this table I'm creating a new one using the query

"CREATE TABLE new TABLE
SELECT ROUND((x-21.45)/5) AS newx,
ROUND((y-18.15)/5) AS newy,
f AS newf FROM oldtable;"

This creates a new table with these 3 fields:
newx DOUBLE(25,0)
newy DOUBLE(25,0)
newf DOUBLE

My question is: how can I alter this query to create a table with the fields:
newx INT
newy INT
newf DOUBLE

Thanks a lot

PS: I know I can create the desired table with a query and then insert the records from a select query, but I'd like to do it in a single query, since I do this on a LOT of tables.
 
alter table TableName modify FieldName FieldType


there is also a change method. try the mysql documentation. its real good...



Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top