Search code examples
mysqlsqldoublequotes

single and double quotes in sql insert


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:

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?


Solution

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

    I hope this helps.