【求sql语句】把1个表中的数据分开插入到3个表中
数据库中一个表里存有数据:
table_QuestionAndAnswer(4列):id(主键)、question、answer、isStored(表示是否被存入到另外三个表中,已存入是1,没有存入是0)
另外三个表:
table_Question(2列):id(主键,触发器生成)、question
table_Answer(2列):id(主键,触发器生成)、answer
table_Relation(3列):id(主键,触发器生成)、question_id(外键,对应table_question的id)、answer_id(外键,对应table_answer的id)
我现在要做的是:把第一个表(table_QuestionAndAnswer)中isStored=0的数据存进后面三个表(table_Question、table_Answer、table_Relation)中,并将isStored改为1。
请教大家sql语句怎么写?
万分感谢!