View Single Post

   
  #7 (permalink)  
Old 02-28-2008, 10:26 AM
Kenoli
 
Posts: n/a
Default Re: Populating 3 tables from 1 record

On Aug 10, 1:12 pm, lyonnyte <lyonn...@gmail.com> wrote:
> On Aug 10, 12:32 pm, "Luuk" <l...@invalid.lan> wrote:
>
>
>
> > "lyonnyte" <lyonn...@gmail.com> schreef in berichtnews:1186771323.329452.184340@i13g2000prf.g ooglegroups.com...

>
> > > Hi everyone,

>
> > > I'm trying to populate 3 tables from 1 record, Not sure if I named it
> > > right, here's an explanation of what I wanted to happen

>
> > > Record 1:
> > > field1| field2| field3| field4| field5| field6| field7|

>
> > > from this record, I would like to make these 3 tables
> > > Table 1
> > > field1| field4| field6

>
> > > Table 2
> > > field2| field3| field5|

>
> > > Table 3
> > > field7|

>
> > > A complication is that there's no primary key to the original table.

>
> > > Is there any way to do this?

>
> > > Thank you for any help you can provide

>
> > INSERT into table1 SELECT field1, field4, field6 FROM table

>
> > INSERT into table2 SELECT field2, field3, field5 FROM table

>
> > INSERT into table3 SELECT field7 FROM table

>
> > i dont get you're 'problem' with no primary key......- Hide quoted text -

>
> > - Show quoted text -

>
> My main problem with no primary key is that I would not be able to
> tell which record in table1 corresponds to records in table2.


So, at present you have no way of selecting a particular row from the
master table aside from selecting on a particular field, which may
return more than one row if there are duplicate entries in that field?

Since, because of this, you are going to have to iterate through the
entire table to create the records you want to create, why not, at the
same time, add a unique id field to the master table and populate it
in the process. Then you could create your additional tables as well
as a linking table to track the relationship between all records.

I normally work with php, a language that interacts with mysql when I
am dealing with mysql data. If you are doing this, which is likely,
you might be able to find a simple solution in that language to what
you are trying to do. It is hard to suggest as you have not
described what you are trying to accomplish by creating these
tables. It might not even be necessary to create these tables. You
might be able to work off of the data in the master table alone.

--Kenoli

Reply With Quote