List:General Discussion« Previous MessageNext Message »
From:Nick Rawlings Date:May 27 1999 12:45am
Subject:Re: AUTOINCREMENT & INSERT ...
View as plain text  
In a true relational database style, you would not be able to create an
organisme record without a pre-existing adresse record to refer to,
providing the addresse record was a required field.  To find the
addresse record you want to join to the organisme record you need to
look through the addresse records to find the id you want.  If you were
using a form, then the addresse id field could be selected from a
drop-list that contained the currently available addresse ids.  If you
are doing everything in the mysql monitor (command line interface) then
you need to do a:

select * from addresse;

to see the addresses to choose the id from.  Then update the organisme
record with:

update organisme set AD_Adresse = '<the id you found>' where OR_Code =
'<id of record you want to update>';

I suggest reading some material on sql database design and working
through any examples; I noticed a book was recommended earlier in this
list:

"An introduction to database systems" by C.J Date.  Addison-Wesley 1995
(6th ed) ISBN 0201824582

Now that you can communicate with mysql ok I forsee your problems now as
being mostly related to just sql syntax and concepts.  It is good to see
you pressing on with the determination and willingness to learn.

>Now, when I add an "organisme", I dont know the adresse yet....so I left the 
>AD_adresse field blank. Then I fill the "adresse" table... Until that point 
>evrythg is going OK... Not bad :))
>But then I d like to update the AD_Adresse of the organisme I have just 
>created....
>For that, I ONLY need the AD_Code of the last insert in adresse table..
>
>  BUT : HOW CAN I GET THE VALUE OF THAT PRIMARY KEY??

-- 
Nick Rawlings			nicholas@stripped
Web Author
HarvestRoad
Thread
AUTOINCREMENT & INSERT ...Sandrine C.26 May
  • Re: AUTOINCREMENT & INSERT ...Erik Liljencrantz26 May
Re: AUTOINCREMENT & INSERT ...jkraai26 May
Re: AUTOINCREMENT & INSERT ...Sandrine C.26 May
  • Re: AUTOINCREMENT & INSERT ...Paul DuBois26 May
    • CHAR and VARCHARRitschie26 May
      • Re: CHAR and VARCHARSasha Pachev26 May
      • Re: CHAR and VARCHARJim Faucette26 May
Re: AUTOINCREMENT & INSERT ...Nick Rawlings27 May