Select with apostrophe

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
Graciela Silva Barbosa
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Tue, 11 Apr 2006 10:03 am
Location: SP

The problem is in the apostrophe

Select all

                 SELECT  * 
                 from   dual 
                 where  'Aparecida d' Oeste' = 'Aparecida d' Oeste';
I tried replace but from the absent right parenthesis error

can anyone help me ????


Thanks
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Put 2 apostrophes!

Select all

 SELECT * 
from dual 
where 'Aparecida d'' Oeste' = 'Aparecida d'' Oeste';  

or CHR (39)

Select all

 SELECT * 
from dual 
where 'Aparecida d'|| chr(39)||' Oeste' = 'Aparecida d'' Oeste';  
: -O
Graciela Silva Barbosa
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Tue, 11 Apr 2006 10:03 am
Location: SP

Thank you for answering,
Congratulations on your effectiveness and efficiency.


But in the case of these my comparisons are returning from the bank
as I could access them so that it could make this exchange to put 2 apostrophes


Thanks
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Inside the bank, the apostrophe gets normal.

there is an example:

Select all

SQL> create table t (campo varchar2(100)); 
 
Table created. 
 
SQL> insert into t values ('That''s the way'); 
 
1 row created. 
 
SQL> select * from t; 
 
CAMPO 
--------------------------------------------------- 
That's the way 
 
SQL> select * from t 
  2  where campo like 'That''s%way'; 
 
CAMPO 
--------------------------------------------------- 
That's the way 
 
SQL> 

That's why using CHR (39) sometimes "complicates less", For you simply concatize the character you want.

Select all

SQL> select * 
  2  from t 
  3  where campo like 'That'|| chr(39) || '%way'; 
 
CAMPO 
------------------------------------------------- 
That's the way 
 
SQL>  
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 8 guests