madjack87 Posted July 14, 2011 Share Posted July 14, 2011 Currently I have a table that is like this. (There are a lot more fields in the real table) ID Company Name Property Name First Name Last Name Mailing Address Property Address Phone Fax Job Type Job Cost Job Status What I would like is to have two tables that are relational Customer Table ID Company Name First Name Last Name Mailing Address Phone Fax Job ID Job Table ID Property Name Property Address Job Type Job Cost Job Status One of my problems though is that If the customer was a residential customer and not a business the address has been going into property address and not mailing. Is there a way to split these tables but in the case where mailing address was blank it will insert the property address for the "mailing address in the new tables"? If not I could possible manually do this. How would I go about splitting them in the first place? Quote Link to comment https://forums.phpfreaks.com/topic/241977-splitting-one-table-into-2-relational-tables/ Share on other sites More sharing options...
biggieuk Posted July 14, 2011 Share Posted July 14, 2011 I think the best way would be to firstly create the 2 new tables in your db. Then write a PHP script that takes all of your table data into an array. You can then loop through each array item and INSERT specific columns into the correct table. You could also put an IF statement in your PHP to check for residential or business and insert the correct address. Quote Link to comment https://forums.phpfreaks.com/topic/241977-splitting-one-table-into-2-relational-tables/#findComment-1242751 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.