* matt > I was wondering how I would insert a value which is present in another > table, specifically, this is a member_id field from a main members table > which acts as a foreign key in this table (Although I know this not > truly possible in MySQL). I think this attempted, although non > functional, insert statement describes what it is I'm trying to do: > > INSERT INTO skills (member_id, name, schooling, certifications, > description) VALUES > (members.max(member_id),'$skill_name','$schooling','$certifications','$s > kill_description')"; > > Would I be best to select this before hand with PHP and somehow store > the result in a variable and then insert it? Thanks very much for the > help.
If all wanted values was available in the member table, you wouldn't need to use a script, but I suspect in this case this is not the case: INSERT INTO skills (member_id, name, schooling, certifications, description) SELECT member_id, '$skill_name','$schooling','$certifications','$skill_description' FROM member ORDER BY member_id DESC LIMIT 1; -- Roger --------------------------------------------------------------------- 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