char comparision [message #306120] |
Wed, 12 March 2008 22:18 |
yes_rajes
Messages: 4 Registered: November 2007 Location: Singapore
|
Junior Member |
|
|
Hi,
How does the following query returns 'TRUE' even though there is an additional space in the right side of the where condition.
Does it mean that the spaces on the right end of the characters will be trimmed by default?
If so, how can i avoid this situation.
SQL> select 'TRUE' from dual where 'rajes' = 'rajes ';
'TRU
----
TRUE
Please clarify me.
Thanks in adv.
Regards,
Rajesh
|
|
|
Re: char comparision [message #306123 is a reply to message #306120] |
Wed, 12 March 2008 22:53 |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
SQL> ed
Wrote file afiedt.buf
1* select decode('rajesh','rajesh','true','false') from dual
SQL> /
DECO
----
true
SQL> ed
Wrote file afiedt.buf
1* select decode('rajesh',' rajesh','true','false') from dual
SQL> /
DECOD
-----
false
SQL> ed
Wrote file afiedt.buf
1* select decode('rajesh','rajesh ','true','false') from dual
SQL> /
DECOD
-----
false
SQL> ed
Wrote file afiedt.buf
1* select decode('rajesh',' rajesh ','true','false') from dual
SQL> /
DECOD
-----
false
SQL>
regards,
|
|
|
|
Re: char comparision [message #306127 is a reply to message #306123] |
Wed, 12 March 2008 23:08 |
yes_rajes
Messages: 4 Registered: November 2007 Location: Singapore
|
Junior Member |
|
|
Hi mshrkshl,
Thanks for the response.
It works fine for the given query.
For better understanding i had hard coded the where condition.
But what I really want to know is how to apply this across the tables.
For ex:
select ctbl1.* from customer ctbl1, customer ctbl2
where ctbl1.customername = ctbl2.customername
and ctbl1.customerid <> ctbl2.customerid
In this scenario customer name 'Rajesh' and 'Rajesh ' should be treated as unequal.
Thanks & Regards,
Rajesh
|
|
|
|
Re: char comparision [message #306129 is a reply to message #306120] |
Wed, 12 March 2008 23:40 |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
one way maybe replace '' by any character.
SQL> ed
Wrote file afiedt.buf
1* select 'TRUE' from dual where 'rajes' = replace('rajes ','','*')
SQL> /
no rows selected
regards,
|
|
|
|
|
|
|
|
Re: char comparision [message #306183 is a reply to message #306141] |
Thu, 13 March 2008 03:07 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
thani_oracle wrote on Thu, 13 March 2008 07:11 | Hi,
What is the diff b/w this?
SQL> select 't' from dual where 'thani'=' true';
no rows selected
SQL> select 't' from dual where 'thani'='true ';
no rows selected
SQL> select 't' from dual where 'thani'=' true ';
no rows selected
Thanks,
Thani.
|
Now that you found the bold-tag, it's only a small step to use the code-tag.
You've been warned often enough now.
[Updated on: Thu, 13 March 2008 03:09] Report message to a moderator
|
|
|
|