-
I've a situation ..like this
data in a particular in colum will end with "_XXXX" , I wanted to retreive these records only .
there are other records in the table with data "XXXXXXXXXX"
When I run this query ..it is picking everything ..?? how come it is looking for "_" .
select column_name from table where column_ name like '_XXXX'
Data in colum
XXXXXXXX
ABC_XXXX
o/p shuld be
ABC_XXXX
but I get
XXXXXXXX
ABC_XXXX
why ?
-
U should use escape characters for this query:
select column_name from table where column_ name like '%\_XXXX' escape '\';
-
The underscore is a wild card operator, you have to escape it.
Code:
SQL> select * from xyz;
X
----------
AAAA_XXXX
XXXXXXXX
XXX_XXXX
SQL> select * from xyz where x like '%_XXXX';
X
----------
AAAA_XXXX
XXXXXXXX
XXX_XXXX
SQL> select * from xyz where x like '%\_XXXX' escape '\';
X
----------
AAAA_XXXX
XXX_XXXX
Jeff Hunter
-
thank U guys ...Learning Oracle never ends ....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|