我在mysql触发器中获取一些数据时遇到问题。
我将表Artikel
的列名存储在一个名为Artikelupdate
的单独表中。以下代码中的subquerys获取Artikel的最后四个列名。
这部分代码无法正常工作:
SELECT (SELECT `name` FROM `Artikelupdate` ORDER BY `id` DESC LIMIT 0, 1) INTO @s24_new FROM `Artikel` WHERE `id`=@id_new;
SELECT (SELECT `name` FROM `Artikelupdate` ORDER BY `id` DESC LIMIT 1, 1) INTO @afi_new FROM `Artikel` WHERE `id`=@id_new;
SELECT (SELECT `name` FROM `Artikelupdate` ORDER BY `id` DESC LIMIT 2, 1) INTO @afi_old FROM `Artikel` WHERE `id`=@id_new;
SELECT (SELECT `name` FROM `Artikelupdate` ORDER BY `id` DESC LIMIT 3, 1) INTO @s24_old FROM `Artikel` WHERE `id`=@id_new;
到目前为止我测试了什么:Artikel
中,因此" WHERE id
= @ id_new"也在努力。 SELECT (SELECT `name` FROM `Artikelupdate` ORDER BY `id` DESC LIMIT 0, 1) INTO @s24_new FROM `Artikel` WHERE `id`=@id_new;
没有将列的值输入@ s24_new,它获取列名(子查询的结果)