How can I include parentheses inside string using string literals in mysql?

Lewis Hepburn :

Problem

I'm trying to alter a variable to my desired string which includes a set parentheses. When doing so, it's trims off the closing parenthesis. I believe I have to include string literals but unsure on how to do so for my particular scenario.

Script (Partial)

...
IF col_datatype = 'varchar' THEN
    SET col_datatype = 'varchar(30)';
    SELECT col_datatype;
END IF;
SELECT col_datatype;
...

Output

Output

Prakhar Londhe :

Try using the backquote `. This is used when you wish to insert non-formatted strings into the database.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=5573&siteId=1