In the last episode (Jun 07), Jule Slootbeek said:
Hey gang,
I have two tables:
user
++--+--+-+-+---+
| Field | Type | Null | Key | Default | Extra |
++--+--+-+-+---+
| user_id| int(10) unsigned | | PRI | NULL| auto_increment|
| first_name | varchar(10) | | | | |
| last_name | varchar(20) | | | | |
| email | varchar(100) | | | | |
| username | varchar(16) | | | | |
| password | varchar(32) | | | | |
++--+--+-+-+---+
and
quiz
+-+--+--+-+-++
| Field | Type | Null | Key | Default | Extra |
+-+--+--+-+-++
| quiz_id | int(10) unsigned | | PRI | NULL| auto_increment |
| user_id | int(10) unsigned | | | 0 ||
| title | varchar(255) | | | ||
+-+--+--+-+-++
now user_id and is a relationship between user and quiz...
How do i make sure that when i insert a new row into quiz that user_id
gets taken from quiz, without me having to look it up in user and
entering it manually?
any ideas?
INSERT INTO users VALUES (NULL,'myfname','mylname','myemail','username','pass');
INSERT INTO quiz VALUES (NULL,LAST_INSERT_ID(), 'title goes here');
--
Dan Nelson
[EMAIL PROTECTED]
$#$@! list filter. sql, query. there. happy?
-
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