Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:08:31+00:00 2026-06-18T02:08:31+00:00

Possible Duplicate: Today, mysql_real_escape_string() is escaping single quotes AND double quotes I understand that

  • 0

Possible Duplicate:
Today, mysql_real_escape_string() is escaping single quotes AND double quotes

I understand that single quotes and backslash have special meaning so they need to be escaped if we want them to be interpreted for their literal meaning.

As far as I understand , double quotes are not allowed in mysql queries to represent strings(if this assumption is correct, is this the only reason to escape them ?) and we should use single quotes instead to represent strings.

And what about NULL? Looking for specific examples to understand why double quotes and NULL need to be escaped.

Just to add, I’ve already searched here on stackoverflow and I see most examples refer to single quotes which I already understand… But I need to understand the reasoning behind double quotes and I cannot find any examples for that…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:08:32+00:00Added an answer on June 18, 2026 at 2:08 am

    In default mode, MySQL allows for string literals to be enclosed in single quotes OR in double quotes.

    SELECT 'single', "double"
    

    For compatibility with other DBMS, and just in case MySQL mode is set to ANSI_QUOTES, most SQL authors use single quotes to specify string literals. There’s really no advantage to using double quotes. (And why write a query in a way that will cause the query to be “broken” when someone changes a variable in their MySQL server session.)

    So, the short answer is that double quotes do not need to be escaped in all cases, e.g.

    SELECT 'Bob cried "Wheeeee!"'
    

    They do need to be escaped in some cases:

    SELECT "Sue screamed \"Stop!\""
    

    But it doesn’t hurt to escape the double quotes in any case:

    SELECT 'Bob cried \"Wheeeee!\"', "Sue screamed \"Stop!\""
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: why does 3,758,096,384 << 1 gives 768 Today I found out that
Possible Duplicate: C++ Static member method call on class instance Today I discovered that
Possible Duplicate: Getting the timestamp from last saturday (every week)? If today is Sunday,
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: How are you using C++0x today? I'm working with a team on
Possible Duplicate: The importance of using a 16bit integer If today's processors perform (under
Possible Duplicate: What is causing Unable to allocate memory for pool in PHP? Today
Possible Duplicate: Calculate difference between 2 date / times in Oracle SQL I have
Possible Duplicate: stop php processing file Today while playing around with PHP a noticed
Possible Duplicate: How to add number of days to today’s date? I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.