Reputation: 1
I need to take the value in a table to generate a URL containing this value and insert it in a new table. Is it possible to use variables within MySQL to form this URL?
Example:
SELECT `identity_id`, `email` FROM `identities` WHERE 1
Output: 1 [email protected]
With the ID and email in hand, I need to insert the HTML content below where the respective email for each ID says VARIABLE.
INSERT INTO `identities`(`html_signature`) VALUES ([<img src="https://example.com/images/VARIABLE.png" width="580" height="138">])
Thanks for help
Upvotes: 0
Views: 29
Reputation: 750
You can use the select into
statement
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
I'm not sure if VARIABLE
represented the id, email, or both but you could change the concat
function arguments as needed.
Upvotes: 1