String data with single quote

Database
Highlighted
Enthusiast

String data with single quote

Hello,

 

I have a column with this data:

 

CITY_NAME
DIAMANTE D'OESTE

 

How to select this registry? I tried this

 

SELECT * FROM ADDRESS WHERE CITY_NAME = "DIAMANTE D'OESTE";

 

but it din't work... thanks ;)


Accepted Solutions
Teradata Employee

Re: String data with single quote

Hi coloric,

 

You have to escape quote in the text with another single quote, like this :

SELECT *
  FROM ADDRESS
 WHERE CITY_NAME = 'DIAMANTE D''OESTE';

The exteriors quotes are also single.

1 ACCEPTED SOLUTION
3 REPLIES
Teradata Employee

Re: String data with single quote

Hi coloric,

 

You have to escape quote in the text with another single quote, like this :

SELECT *
  FROM ADDRESS
 WHERE CITY_NAME = 'DIAMANTE D''OESTE';

The exteriors quotes are also single.

Enthusiast

Re: String data with single quote

Thank you so much, Waldar!

Teradata Employee

Re: String data with single quote

The outer quotes must be single ' and the embedded quote is escaped by entering two in a row:

SELECT * FROM ADDRESS WHERE CITY_NAME = 'DIAMANTE D''OESTE';