Jump to content

Recommended Posts

ihave this table structure

CREATE TABLE staff_details_tbl (
staff_id          INT UNSIGNED NOT NULL AUTO_INCREMENT,
SUsername_id   varchar(255),
Fname VARCHAR(60) NOT NULL,
Lname VARCHAR(60) NOT NULL,
D_O_B date,
PRIMARY KEY (staff_id )
);

Fname and Lname for more than 1 human being can be the same
i have this stored procedure code:

declare l_staff_id int;
  insert into staff_details_tbl (Fname,Lname,D_O_BSUsername_id)values(inFname,inLname,inBdate,' ');
select staff_id  into l_staff_id from staff_details_tbl where Fname=inFname and Lname=inLname ;
insert into staff_job_tbl(staff_id,Team_catId,job_id)values(l_staff_id,inteam,injob);

ihave to select the staffid for insert into another table,
there are some problems with using the last_insert_id()  that is why i choose to select the staff_id here.


but with no unique Fname or Lname,the repetition of same names  causes an error of REsult contained more than one row

 no unique key because there re many people with a name like 'kamikazi' google and see.
I need a way of getting that id how can I go about this??

Link to comment
https://forums.phpfreaks.com/topic/303562-use-last_insert_id-not/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.