PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Re: How do I copy records and their relational records too?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Re: How do I copy records and their relational records too?

Réponse
 
LinkBack Outils de la discussion
Vieux 04/02/2008, 23h17   #1
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I copy records and their relational records too?

dterrors@hotmail.com wrote:
> On Feb 4, 4:55 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
>> dterr...@hotmail.com wrote:
>> > I can't do insert...select because the keys will all be different
>> > on the newly copied tables.

>>
>> Why?

>
> Because I'm copying records. So therefore their keys will be
> different. Unique keys? Two records can't have the same key?


But you are copying to new tables, so there will still only be one of each
key in the table.


  Réponse avec citation
Vieux 04/02/2008, 23h23   #2
dterrors@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I copy records and their relational records too?

On Feb 4, 5:17 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
> dterr...@hotmail.com wrote:
> > On Feb 4, 4:55 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
> >> dterr...@hotmail.com wrote:
> >> > I can't do insert...select because the keys will all be different
> >> > on the newly copied tables.

>
> >> Why?

>
> > Because I'm copying records. So therefore their keys will be
> > different. Unique keys? Two records can't have the same key?

>
> But you are copying to new tables, so there will still only be one of each
> key in the table.


I'm copying to the same table.

Although even if it was to a new table- how do I link up the binding
table (table c)? Table c's value for db_a_id is no longer relevant.
It may have "15" where there is no 15 in the new table (or 15 is
something else).

I'm trying to copy individual (set of records). As in "copy record 12
of table a and include (also make copies of) everything that relates
to it in table b, including the relationship record in table c"

The new relationship record needs to be aware of the new a and b keys.

  Réponse avec citation
Vieux 04/02/2008, 23h43   #3
Paul Lautman
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I copy records and their relational records too?

dterrors@hotmail.com wrote:
> On Feb 4, 5:17 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
>> dterr...@hotmail.com wrote:
>> > On Feb 4, 4:55 pm, "Paul Lautman" <paul.laut...@btinternet.com>
>> > wrote:
>> >> dterr...@hotmail.com wrote:
>> >> > I can't do insert...select because the keys will all be
>> >> > different on the newly copied tables.

>>
>> >> Why?

>>
>> > Because I'm copying records. So therefore their keys will be
>> > different. Unique keys? Two records can't have the same key?

>>
>> But you are copying to new tables, so there will still only be one
>> of each key in the table.

>
> I'm copying to the same table.
>
> Although even if it was to a new table- how do I link up the binding
> table (table c)? Table c's value for db_a_id is no longer relevant.
> It may have "15" where there is no 15 in the new table (or 15 is
> something else).
>
> I'm trying to copy individual (set of records). As in "copy record 12
> of table a and include (also make copies of) everything that relates
> to it in table b, including the relationship record in table c"
>
> The new relationship record needs to be aware of the new a and b keys.


I quote: "I can't do insert...select because the keys will all be different
on the newly copied tables."

If you were doing what you said you were doing, copying to new tables, then
there would be no reason for the keys to change, in any of the 3 tables.
That is the reason I asked "why", because your question did not make sense.


  Réponse avec citation
Vieux 04/02/2008, 23h46   #4
dterrors@hotmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I copy records and their relational records too?

On Feb 4, 5:43 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
> dterr...@hotmail.com wrote:
> > On Feb 4, 5:17 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
> >> dterr...@hotmail.com wrote:
> >> > On Feb 4, 4:55 pm, "Paul Lautman" <paul.laut...@btinternet.com>
> >> > wrote:
> >> >> dterr...@hotmail.com wrote:
> >> >> > I can't do insert...select because the keys will all be
> >> >> > different on the newly copied tables.

>
> >> >> Why?

>
> >> > Because I'm copying records. So therefore their keys will be
> >> > different. Unique keys? Two records can't have the same key?

>
> >> But you are copying to new tables, so there will still only be one
> >> of each key in the table.

>
> > I'm copying to the same table.

>
> > Although even if it was to a new table- how do I link up the binding
> > table (table c)? Table c's value for db_a_id is no longer relevant.
> > It may have "15" where there is no 15 in the new table (or 15 is
> > something else).

>
> > I'm trying to copy individual (set of records). As in "copy record 12
> > of table a and include (also make copies of) everything that relates
> > to it in table b, including the relationship record in table c"

>
> > The new relationship record needs to be aware of the new a and b keys.

>
> I quote: "I can't do insert...select because the keys will all be different
> on the newly copied tables."
>
> If you were doing what you said you were doing, copying to new tables, then
> there would be no reason for the keys to change, in any of the 3 tables.
> That is the reason I asked "why", because your question did not make sense.


Good point. I said "tables" where I meant "records" in that sentence.

  Réponse avec citation
Vieux 05/02/2008, 19h31   #5
Ed Prochak
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How do I copy records and their relational records too?

On Feb 4, 5:23pm, dterr...@hotmail.com wrote:
> On Feb 4, 5:17 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
>
> > dterr...@hotmail.com wrote:
> > > On Feb 4, 4:55 pm, "Paul Lautman" <paul.laut...@btinternet.com> wrote:
> > >> dterr...@hotmail.com wrote:
> > >> > I can't do insert...select because the keys will all be different
> > >> > on the newly copied tables.

>
> > >> Why?

>
> > > Because I'm copying records. So therefore their keys will be
> > > different. Unique keys? Two records can't have the same key?

>
> > But you are copying to new tables, so there will still only be one of each
> > key in the table.

>
> I'm copying to the same table.
>
> Although even if it was to a new table- how do I link up the binding
> table (table c)? Table c's value for db_a_id is no longer relevant.
> It may have "15" where there is no 15 in the new table (or 15 is
> something else).
>
> I'm trying to copy individual (set of records). As in "copy record 12
> of table a and include (also make copies of) everything that relates
> to it in table b, including the relationship record in table c"
>
> The new relationship record needs to be aware of the new a and b keys.


such are the troubles of those blindly using autonum for the primary
key.
Regular readers of this group have been warned about blindly using
autonum PKs.

You will have to basically follow the same logic you did for inserting
the first set of data. This is beyond straight SQL to solve. You will
need to write a copy program in a procedural language like PERL or C.
It shouldn't take too long to write.

Good luck.
Ed
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h00.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12530 seconds with 13 queries