Thanks for all who responded. But my problem is how to make the sql statement to convert ' to ''.
The Search Form is like : SEARCH __________. People would put in Keyword like VIP or VIP's If it is VIP, I have no problem with SQL behind the form,
" select * from table where title='Keyword'.
If it is VIP's, it gives error cause it doesnt recognize " ' ". I need to modify the sql statement to convert ' to ''. I am trying to use decode to convert, but I have not found the right way yet. I hope there might be some kind of function to do if ', then ''.
Thanks!
Moovarkku Mudhalvan <moovarkku.[Email Address Removed] wrote:
Hi
Greetings. Check this..
SQL> insert into emp values(2,'MM''S',3000,300);
1 row created.
SQL> select * from emp;
ENO EMPNAME BASIC HRA
---------- ---------- ---------- ----------
1 Mudhalvan 12500 500
2 Raja 13600 500
3 Balu 14500 500
4 Reka 14000 500
Raja's
2 MM'S 3000 300
6 rows selected.
SQL> select * from emp where empname like '%''%';
ENO EMPNAME BASIC HRA
---------- ---------- ---------- ----------
Raja's
2 MM'S 3000 300
Thanks
Mudhalvan M.M
I am trying to find a way to write a select statement that can recognize
single quote. The situation is,
In a SEARCH form used on a website , a select statement is used to
select title or name when a Search Keyword is given. The statement behind
the form is
select * from table where title or name='SEARCH KEYWORD';
Some of the title or name contains " ' " , such as VIP'S. The above
statemet will create error if the Search Keyword contains an " ' " like
VIP'S. I understand to select single quote in sql statement should be
like ' select * from table where title=' VIP''S'. But how can I correct
the above statement to recognize a single quote contained in the Search
Word? When people put in search key word, they are not going to put an
extra ' before a single quote.
Appreciate your help!
Sean
------
---------------------------------
Do You Yahoo!?
Yahoo! Health - Feel better, live better
Oracle LazyDBA home page