MySQL Forums
Forum List  »  General

combine INSERT... VALUES and INSERT... SELECT
Posted by: eykanal
Date: March 14, 2005 03:40PM

I have the following rather complex select statement which I suspect is not possible:

insert into study_sessions
(timeslot , visitnumber , behav_fmri , participant_id )
values
(now(), 1,behav,%s)
select participant_id as %s from participants where user_id='3' and study_id='3';

I'm not sure what the syntax should be, hence it probably makes no sense now. Basically, I want to insert a bunch of values, along with an INSERT... SELECT (the %s entry) based on a value in a different table. I tried doing it as a subquery:

insert into study_sessions
(timeslot , visitnumber , behav_fmri , participant_id )
values
(now(), 1,behav,
(select participant_id from participants where user_id='3' and study_id='3'));

but that didn't work either. If anyone knows how to get either of these working, I'd be most appreciative. Thanks!

Options: ReplyQuote


Subject
Written By
Posted
combine INSERT... VALUES and INSERT... SELECT
March 14, 2005 03:40PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.