0

Possible Duplicate:
The equivalent of SQLServer function SCOPE_IDENTITY() in mySQL?

i have created data entry form in my web application using codeigniter. In my database, i have two table, for example table A and B.

Example of the table structure

A ( id_a, name, sex, id_b ) B ( id_b, address, hobby, school )

I set autoincrement for id_a and id_b,, the values for table A and B is getting from the data entry form after submitted by user in my web application.

After user submit the form, first table B will be insert and next table A also insert. How to set the id_b in table A using the value of id_b in table B automatically same when user submit the form, so i can use the id_b as the foreign key. Thank you.

Community
  • 1
  • 1
beben
  • 55
  • 2
  • 13
  • Take a look at http://stackoverflow.com/questions/11161448/reference-auto-increment-columns/11161483#11161483 – GDP Jun 24 '12 at 16:17
  • Thank you so much,, i can use $this->db->insert_id() in codeigniter.. One question,, my web apllication is multi user that have large user,, is it problem if maybe two or more users submitted data at the same time,, will it disturb the consistency of my data in database ?? thank you... – beben Jun 24 '12 at 17:01

0 Answers0