如何在存储过程中,设置一个变量表示一个要查询的表名??? 各路大仙速来相助!!!
BEGIN
DECLARE id int(4);
DECLARE questionType char(50); ------用来表示要查询表的名称
SELECT QuestionTypeName INTO questionType FROM question_types WHERE question_types.QuestionTypeId = questionTypeId; --------给questionType赋值,根据输入参数questionTypeId从qustion_types表中得到
INSERT INTO questionType (Question, Answer) VALUES (question, answer);----问题就在这里,我运行数据库报错说没有questionType这张表,可是我已经给questionType赋值了啊。。。
SET id = last_insert_id();
INSERT INTO questions (QuestionType, Id, Point, Level) VALUES (questionTypeId, id, point, level);
END