Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple inserts into 5 tables 1

Status
Not open for further replies.

Lladros

Programmer
Feb 21, 2008
18
US
Hello All!

I have to insert mutiple rows into 5 tables. Basically, I am trying to copy the previous year's entries into the same tables with a new year. Is this possible? (Doing and insert with inner joins)

INSERT INTO a.module_title, a.module_desc, a.module_instructor, a.module_schlyr, b.lesson_title, b.lesson_text, b.lesson_schlyr, c.question_desc, c.question_schlyr, d.answer_text, d.answer_schlyr, e.instruction_text, e.instruction_schlyr
SELECT a.module_title, a.module_desc, a.module_instructor, '2009', b.lesson_title, b.lesson_text, '2009', c.question_desc, '2009', d.answer_text, '2009', e.instruction_text, '2009'
FROM module as a INNER JOIN lessons as b ON a.module_id=b.lesson_mod_id INNER JOIN questions AS c ON b.lesson_id = c.question_lesson_id INNER JOIN instructions AS e ON e.question_instruction_id = c.question_id INNER JOIN answers AS d ON c.question_id = d.answer_quest_id WHERE a.module_id = '132'AND a.module_schlyr = '2008'

I keep getting an error of:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near ','.

I know this is probably as clear as mud! Please help, if you can!

Lladros
 
you need a table name....

INSERT INTO TAbleName(fields, fields, etc.)
 
Don't think that you can insert like this...into multiple tables from one insert statement.
 
You should have many insert statements, each of them inserting in one table.

-------------------------------------------------------------------------------------------------------------------------
"Now I can look at you in peace; I don't eat you any more." Franz Kafka, while admiring fish in an aquarium
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top