Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How compare CHAR and VARCHAR2

Re: How compare CHAR and VARCHAR2

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 27 Apr 2005 15:59:24 -0800
Message-ID: <4270194c@news.victoria.tc.ca>


Andriy Shafar (cutwater_at_wp.pl) wrote:
: Hi.

: I have a problem.

: How I can compare CHAR and VARCHAR2?

: EX.
: column_char CHAR(10);
: column_varchar2 VARCHAR2(10);
: SELECT * FROM tab WHERE column_char LIKE column_varchar2.

Depends exactly what you are trying to compare. You can do things like

SELECT * FROM tab
WHERE
        ltrim(rtrim(column_char)) like '%'||column_varchar2||'%';

which would remove extra padding spaces in the char column and then check if that string is embedded some where in the varchar column. Other functions such as UPPER can help if you want a case sensive comparison.

In case it isn't obvious, in my example the comparison is taking place between two columns in the same row of the same table. If that isn't what you mean then you would have to explain more.

--

This space not for rent.
Received on Wed Apr 27 2005 - 18:59:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US