-2

I am having query for fetching values from table like

Select email from cust Where name = " John carter's "

i am getting error due to single quotation in string....

please help me for the above problem

Vadim K.
  • 2,370
  • 18
  • 26
  • 1
    possible duplicate of [How do I escape a single quote in SQL Server?](http://stackoverflow.com/questions/1586560/how-do-i-escape-a-single-quote-in-sql-server) – Tab Alleman Oct 30 '14 at 19:43

4 Answers4

2

This should work:

Select email from cust Where name = " John carter''s" 
  • If i have this type of query then Select email from cust Where name = 'John carter's' – user3656418 Oct 30 '14 at 19:48
  • @user3656418 in that case, add only an other `'` before your second single quote like this: `Select email from cust Where name = " John carter''s''" ` –  Oct 30 '14 at 19:50
0

if this is something you just need to get right now...

Select email from cust Where name LIKE "%John carter%"

or you can escape the apostrophe:

Select email from cust Where name = " John carter''s" 
Hituptony
  • 2,740
  • 3
  • 22
  • 44
0

Why don't you use the escape character?

Like this

Select email from cust Where name = " John carter''s "
0

The problem you're encountering is caused by the fact that (depending on which database program you're using) the single quote ' is a SQL data-modelling language (DML) delimiter, so the SQL parser may not be able to properly handle it.

Alex Marshall
  • 10,162
  • 15
  • 72
  • 117