Hi,
I am trying to generate an sql query to insert several pieces of data, most of which comes from another table, however I have one variable that comes from PHP variables as below:
insert into scores (AuditID, question_id, available_score, question, question_number, question_section) values ($auditvalue, (SELECT questions.quid, questions.question_value, questions.question, questions.question_number, questions.question_section FROM questions))
the following code works, however because I cannot figure this out, the AuditID column is being left blank and I need it to be populated - I cannot update after insert because the table will contain duplicate values:
insert into scores (question_id, available_score, question, question_number, question_section) SELECT questions.quid, questions.question_value, questions.question, questions.question_number, questions.question_section FROM questions
basically - the 'quid', 'question_value', 'question', 'question_number', 'question_section' from the 'questions' table needs to be copied in to the scores table, but whilst inserting, for each inserted row, i need to insert the '$auditvalue' variable from PHP in to the 'AuditID' column.
Can anyone point me in the correct direction for doing this as I know the above is wrong (I get 'column count does not match' error) - I am using a MySQL database for this. I jiust need to be able to get the AuditID inserted!