![](/img/trans.png)
[英]Get the value from a variable of a table and INSERT into the new table with extra variable for the new table not working?
[英]MYSQL get data from table and insert on new table with variable
我需要获取表中的值以生成包含此值的 URL 并将其插入新表中。 是否可以使用 MySQL 中的变量来形成这个 URL?
例子:
SELECT `identity_id`, `email` FROM `identities` WHERE 1
Output:1个马塞洛@test.com
有了 ID 和 email,我需要在下面插入 HTML 内容,每个 ID 对应的 email 表示 VARIABLE。
INSERT INTO `identities`(`html_signature`) VALUES ([<img src="https://example.com/images/VARIABLE.png" width="580" height="138">])
感谢帮助
您可以使用select into
语句
INSERT INTO `identities` (`html_signatures`)
SELECT CONCAT("<img src=\"https://example.com/images/", `email`, ".png\" width=\"580\" height=\"138\">") as html_signatures
FROM `identities` WHERE 1
我不确定VARIABLE
是否代表 id、email 或两者,但您可以根据需要更改concat
function arguments。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.