question

MattiaCammalleri-7559 avatar image
0 Votes"
MattiaCammalleri-7559 asked Yufeishao-msft answered

custom character for strings on mysql workbench

Hi,
i have a string that contains both characters ' and ", i need to use this strings inside an insert.
The problem is that due to those characters the strings results "splitted" therefore invalid.
Can i change the characters ' and " to some other characters?

sql-server-general
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MattiaCammalleri-7559 avatar image
0 Votes"
MattiaCammalleri-7559 answered

The string that i have to insert contain the 2 characters for string so i the command input is invalid. please check here: ibb.co/34SqNxv and see how i'm trying to insert the string " Contenuto1"' " bu since the string contain those special chaacters the command become invalid.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered ErlandSommarskog commented

Try using ' to write the strings and double each ' that appears inside the text. For example:

  • 'a''b' — two ' between a and b denotes a single '.

The quotation mark (") can be written directly inside such strings.




· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I would like to do something like this:
$string"'"'abc$.
Is possible to replace ' and " as a syntax characters?

0 Votes 0 ·
ErlandSommarskog avatar image ErlandSommarskog MattiaCammalleri-7559 ·

In T-SQL, you do as Viorel says, to include a single quote in a string, you double. And the same is true with other closing delimiters. For instance:

`
SELECT 'My single''quote' AS "my double""quote"

`I would expect this to apply to other SQL dialects as well. If the subject line is to be trusted, you are using MySQL, and if so, you should consult an MySQL forum for an authoritative answer. This forum is for Microsoft SQL Server, a different product.

0 Votes 0 ·
Yufeishao-msft avatar image
0 Votes"
Yufeishao-msft answered

Hi @MattiaCammalleri-7559,

SQL Server is really different from MySQL, I suggest you can go to a MySQL related for advice.

If you can try to replace the ‘ and “ with other characters in a MySQL column?

https://stackoverflow.com/questions/7734077/mysql-replace-character-in-columns

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.