sql插入中的单引号和双引号

时间:2022-09-15 13:37:06

I had an issue come up when working with mySQL. I have a table of parts with part numbers and descriptions. I am trying to insert over a thousand parts and need to get the formatting to work for every insert. For some parts the description (text type) will be something like:

使用mySQL时遇到了一个问题。我有一个零件表,其中包含零件编号和说明。我试图插入超过一千个部分,需要格式化为每个插入工作。对于某些部分,描述(文本类型)将类似于:

TUBE 1/2" X .049" UNANODIZED 6061 T6 12'

TUBE 1/2“X .049”UNANODIZED 6061 T6 12'

I tried numerous combinations of quotes but because it uses single and double quotes it's a real pain to insert as text. How can I do this so that it will work for all inserts, even those without any special characters?

我尝试了多种引号组合,但由于它使用单引号和双引号,因此插入文本非常痛苦。我该怎么做才能使它适用于所有插入,即使没有任何特殊字符的插入?

2 个解决方案

#1


0  

Use a backslash to escape the symbol: 'TUBE 1/2\" X .049\" UNANODIZED'

使用反斜杠来转义符号:'TUBE 1/2 \“X .049 \”UNANODIZED'

I hope this helps.

我希望这有帮助。

#2


0  

Everytime you use a single or double quote , use the backslash character to escape it TUBE 1/2\" X .049\" UNANODIZED 6061 T6 12\'

每次使用单引号或双引号时,请使用反斜杠字符将其转义为TUBE 1/2 \“X .049 \”UNANODIZED 6061 T6 12 \'

#1


0  

Use a backslash to escape the symbol: 'TUBE 1/2\" X .049\" UNANODIZED'

使用反斜杠来转义符号:'TUBE 1/2 \“X .049 \”UNANODIZED'

I hope this helps.

我希望这有帮助。

#2


0  

Everytime you use a single or double quote , use the backslash character to escape it TUBE 1/2\" X .049\" UNANODIZED 6061 T6 12\'

每次使用单引号或双引号时,请使用反斜杠字符将其转义为TUBE 1/2 \“X .049 \”UNANODIZED 6061 T6 12 \'