Matt,

Being that I am a PHP developer, the answer is right there in front of you.
Since you are getting the member_id after you insert the first bunch of
information, the best way you can do this in my experience is to create a
search group and reference the information that you just got, so you can get
your member_id.  From there you can now store that member_id into a variable
and use it at will.

If there is a better way of doing this, I would LOVE to know it.

-- Mike Eggleston
-- [EMAIL PROTECTED]

----- Original Message -----
From: "Matt Rudderham" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, December 28, 2001 2:05 PM
Subject: Programming for referential integrity


> Hello,
> Forgive me for what is probably a fairly novice question as I am still
> fairly new to MySQL.  I have constructed the following database with
> three tables:
>
> CREATE TABLE members (
> member_id int DEFAULT '0' NOT NULL AUTO_INCREMENT PRIMARY KEY,
> first varchar(20) NOT NULL,
> last varchar(20) NOT NULL,
> position varchar(20),
> organization varchar(35),
> address varchar(255),
> postal_code varchar(7),
> county varchar(15) NOT NULL,
> phone varchar(20),
> fax varchar(20),
> email varchar(40),
> website varchar(50),
> member_type varchar(20) NOT NULL,
> on_directory char(1)  NOT NULL DEFAULT 'N',
> on_website char(1) NOT NULL DEFAULT 'N',
> description BLOB
> );
>
> CREATE TABLE skills (
> skills_id int default '0' not null auto_increment primary key,
> member_id int not null references members(member_id),
> name varchar(20) NOT NULL,
> schooling varchar(20) NOT NULL,
> certifications varchar (20) NOT NULL,
> decription BLOB
> );
>
> CREATE TABLE committees (
> committees_id int DEFAULT '0' NOT NULL AUTO_INCREMENT PRIMARY KEY,
> member_id int not null references members,
> name varchar(25)
> );
>
> I would like the member_id field present in all of the tables to link
> the skills and commitees to a specific member_id.  I was looking at the
> last_insert_id() function as a possible way to do this as initially all
> of this information will be entered at once. What is the best way to
> find the member_id that was just created in the members table and insert
> it into the skills table and the committees table when adding the
> information about those members? I am using PHP and MySQL 3.23.38
> running on FreeBSD / Apache(PhP4). Thanks.
>
> Matt Rudderham
>
>
>  "Bonum volens duceris in Tartarum"
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to