List:MySQL on Win32« Previous MessageNext Message »
From:John Philip Date:January 20 2004 6:59am
Subject:RE: storing last_insert_id in a string
View as plain text  


Hi,
 I am try to insert the unique key of contract into cheque details. FK
is
custid of contract


Eg:

Contract:

CustId	Name
2 		contract 1


Cheque Details:
Custid 	Chqid		chqno
2		1		123456
2		2		123457
2		3		123458
2		4		123459

Now last_insert_id will have value '2'  ,
Inserted first row to cheque details, now the last_insert_id is '1'.
As no. of rows I insert into chequedetails the last_insert_id keep
changing this?
So I want to store last_insert_id() into a variable and then store into
chequedetails custid with that variable.

Regards
John 

-----Original Message-----
From: robert_rowe [mailto:robert_rowe@stripped] 
Sent: Tuesday, January 06, 2004 20:28
To: win32@stripped
Subject: Re: storing last_insert_id in a string



Instead of storing the multiple keys of chequedetails in your contract
table, store the single key from contract in each of your chequedetails
records. This does require that contract be inserted before
chequedetails but it will use the standard one to many relationship and
allow you to craft a join query to return the results later.


-- 
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe:
http://lists.mysql.com/win32?unsub=1



-- 
MySQL Windows Mailing List
For list archives: http://lists.mysql.com/win32
To unsubscribe:
http://lists.mysql.com/win32?unsub=1

Thread
storing last_insert_id in a stringJohn Philip6 Jan
  • Re: storing last_insert_id in a stringrobert_rowe6 Jan
    • RE: storing last_insert_id in a stringJohn Philip7 Jan
      • RE: storing last_insert_id in a stringJohn Philip20 Jan