simcoweb Posted January 17, 2008 Share Posted January 17, 2008 I'm writing a query to create a table but want to also provide entries into those fields as values at the same time. I know the syntax for the table creation but can't find a reference anywhere (include mysql site and cheat sheets, etc.). Here's a sample of what I have. Just looking for the right syntax to insert the values at the same time of creation. mysql_query("CREATE TABLE property_types( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), propertytypes VARCHAR(100), property_type2 VARCHAR(100), property_type3 VARCHAR(100), property_type4 VARCHAR(100), property_type5 VARCHAR(100), property_type6 VARCHAR(100), property_type7 VARCHAR(100), property_type8 VARCHAR(100), property_type9 VARCHAR(100), property_type10 VARCHAR(100), property_type11 VARCHAR(100), property_type12 VARCHAR(100), property_type13 VARCHAR(100), property_type14 VARCHAR(100), property_type15 VARCHAR(100), property_type16 VARCHAR(100), property_type17 VARCHAR(100), property_type18 VARCHAR(100), property_type19 VARCHAR(100), property_type20 VARCHAR(100), property_type21 VARCHAR(100), property_type22 VARCHAR(100), property_type23 VARCHAR(100), property_type24 VARCHAR(100), property_type25 VARCHAR(100), property_type26 VARCHAR(100), property_type27 VARCHAR(100), property_type28 VARCHAR(100)") or die(mysql_error()); echo "Table successfully created!";(100), Quote Link to comment Share on other sites More sharing options...
beebum Posted January 18, 2008 Share Posted January 18, 2008 You can't create and insert all in the same command. You can, however, create and copy from another table all in one command. See the bottom few examples. http://dev.mysql.com/doc/refman/5.0/en/create-table.html Quote Link to comment Share on other sites More sharing options...
fenway Posted January 18, 2008 Share Posted January 18, 2008 Wow, that's a terrible table design... re-think this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.