Jump to content

Recommended Posts

I have a table that has a list of names. 1 name per row.

I would like to create a table for each name in the table using the name as the table name.

 

i.e.

Table of Names

jon

bob

jess

cat

 

creates 4 tables with fields (address, Phone, email,note)

table jon

table bob

table jess

table cat

 

 

Is there a fast way to do this?

 

Link to comment
https://forums.phpfreaks.com/topic/298645-creating-new-tables/
Share on other sites

Perhaps you should detail exactly what you have and exactly what you are trying to accomplish. I for one don't understand. It would greatly help if you posted an SQL dump of your "Normalized Master Database" along with sample data and details of what you want to do with it. "Analyze" doesn't tell us anything, neither does time series.

 

Regardless of what your doing, creating all those tables is just wrong. Doing the wrong thing never saves time.

Edited by benanamen
Link to comment
https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523476
Share on other sites

Depending what "note" holds and it's size you may need to create another table for that one and just just link to it using a foreign key.

CREATE TABLE IF NOT EXISTS Person(
id int unsigned NOT NULL AUTO_INCREMENT,
firstname varchar(150),
lastname varchar(250),
address varchar(250),
phone varchar(100),
email varchar(150),
note varchar(250),
PRIMARY KEY(id))

INSERT INTO Person(firstname,lastname,address,phone,email,note)
VALUES('jon','lastname','address','phone','email','note'),
('bob','lastname','address','phone','email','note'),
('jess','lastname','address','phone','email','note'),
('cat','lastname','address','phone','email','note')
Link to comment
https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523510
Share on other sites

@hansford, not sure what your post has to do with the limited info the OP provided, but there would need to be four more tables needed for your example for a properly normalized DB. Another one for address, another one phones along with a phones type table, another one email/electronic communications, and another one note, all of which has nothing to do with "Person" data.

 

Person data would be first, middle and last name, sex, birthdate, hair color, eye color, height and weight, ethnicity, active/inactive, marital status (unless you are tracking those over time, then separate tables for those)

Edited by benanamen
Link to comment
https://forums.phpfreaks.com/topic/298645-creating-new-tables/#findComment-1523511
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.