问题遇到的现象和发生背景
想用触发器,然后编辑了一下 如下面代码,--插入格式是可以运行的,但是在填写字段名的地方用查询的方法书写就失效了
问题相关代码,请勿粘贴截图
-- 触发器设置
INSERT INTO xinku(xinku.(SELECT ValueId FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1 ), timeStamp) VALUES(
(SELECT realValue FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1),
(SELECT timeStamp FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1));
-- 插入格式
INSERT INTO xinku (xinku.350,timeStamp) VALUES(
(SELECT realValue FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1),
(SELECT timeStamp FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1));
运行结果及报错内容
[SQL]INSERT INTO xinku(xinku.(SELECT ValueId FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1 ), timeStamp) VALUES(
(SELECT realValue FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1),
(SELECT timeStamp FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1));
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT ValueId FROM equipmentdata ORDER BY equipmentdataId DESC LIMIT 1 ), tim' at line 1
我的解答思路和尝试过的方法
想用单引号,双引号都无法解决
我想要达到的结果
如何才能运行起来 是这个不能再字段名这用查询来输出成字段么