MySql触发concat新关键字 [英] MySql trigger concat new keyword
本文介绍了MySql触发concat新关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前在使用concat函数将NEW关键字与列名连接时遇到问题。
I am currently facing an issue in concatenating "NEW" Keyword with column names using concat function..
SET @values =
(SELECT GROUP_CONCAT(CONCAT_WS('.','new', table1.col) SEPARATOR ',')
FROM tbale1, table2, table3, table4
WHERE table3.table3_id = '001'
AND table3.id = table4.table3_id
AND table4.col = table2.col
AND table1.id = table2.table1_id
ORDER BY table2.col);
执行时,而不是替换NEW关键字的值(最后插入记录/值)它只返回NEW.col1,NEW.col2,NEW.col3而不是它们指定的值。请帮我解决这个问题..
期望的输出是SELECT @var ='aa','bb','cc','ccc';但是当前输出是SELECT @var = NEW.col1,NEW.col2,NEW.col3,NEW.col4;
ON execution, instead of replacing the values for NEW keyword(last inserted records/values) it just returns as NEW.col1,NEW.col2,NEW.col3 instead of their assigned values.please help me out with this..
desired output is SELECT @var ='aa','bb','cc','ccc'; But current output is SELECT @var = NEW.col1,NEW.col2,NEW.col3,NEW.col4;
推荐答案
看起来你正在尝试创建一个动态SQL语句。
在MySQL中,这称为准备语句,你可以在这里查阅参考手册:
13.5准备语句的SQL语法 [ ^ ]
有时MySQL文档不提供最容易理解的例子,所以这里有另一个链接: MySQL准备语句 [ ^ ]
我希望这可以帮助你。
It looks like you are trying to create a SQL statement dynamically.
In MySQL this is called Prepared Statements and you can look up the reference manual here:
13.5 SQL Syntax for Prepared Statements[^]
Sometimes the MySQL documentation doesn't provide the easiest to understand examples, so here is another link: MySQL Prepared Statement[^]
I hope this helps you on the way.
这篇关于MySql触发concat新关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文