Select and insert into php/mysql


#1

hello i have 2 tables account_info and patient_info i want the user to fill first the account_info table and then the patient_info
but i have to select account_id and patient_username from account_info and insert them in patient_info then the user enters patient name and the rest of the information
i have :

  $sql  = "INSERT INTO patient_info(p_username, acc_id, p_fname, p_lname, p_gender, p_condition, 
 p_birthdate, p_emergencycontact) 
					SELECT p_username, acc_id
						FROM account_info      
  VALUES(:p_fname, :p_lname, :p_gender, :p_condition, :p_birthdate, 
:p_emergencycontact)";

#2

Wouldn’t this be better suited on a MySQL/PHP forum?

Anyway, as far as I know you can’t mix INSERT INTO SELECT FROM with VALUES. I could be wrong, and/or I could have just been using a SQL implementation that didn’t support things like that.


#3

of course ! thank you