I am working with a program that allows me to execute SQL after downloading an image. The program also provides tokens which give a specific value depending on the image downloaded. To do this it provides a form field which I have filled with:
INSERT INTO tag_index (tag, index_count) VALUES ("%type%:%tag%", 1) ON DUPLICATE KEY UPDATE index_count = index_count + 1;
I would expect this to insert "location:italy"
into tag_index
.
However, the values tokens return are surrounded by single quotes. Going by the previous example "'location':'italy'"
gets inserted into tag_index
instead.
Having these single quotes in tag_index
is incompatible with the gallery application I am using, and I cannot edit the application I am downloading the images with to make the tokens not surrounded by single quotes. I need to be able to write a line of SQL that can fit in the downloader applications settings field that removes just the outer single quotes when inserting into tag_index
.
For example, would it be possible to do something like:
INSERT INTO tag_index(tag, index_count) VALUES ("ESCAPEOUTERQUOTES(%type%):ESCAPEOUTERQUOTES(%tag%)", 1)
ON DUPLICATE KEY UPDATE index_count = index_count + 1;
I am using MySQL 5.7.23.
Edit
As suggested by some comments, I do not think using REPLACE
would answer my question. A %tag%
token can include valid single quotes. For example, when a tag resembles a face ''o''
I need to only remove the outer single quotes leaving 'o'
.