How do I compare two columns in a two different table that are of type LONG? [message #374106] |
Thu, 24 May 2001 20:30 |
Khanh Hua
Messages: 7 Registered: May 2001
|
Junior Member |
|
|
I would like to do a join between two tables on a column that is of type LONG.
I tried doing something like this:
Example:
select a.emp_id, b.dept_id from emp a, dept b
where a.dept_id = b.dept_id AND
a.desc like '%b.desc%'
but the results did not join based on the desc column between the two tables. I suspect it is because the dataType is LONG for the desc column.
Any help would be much appreciated.
Thanks
|
|
|
|
|
|
Re: How do I compare two columns in a two different table that are of type LONG? [message #374119 is a reply to message #374106] |
Fri, 25 May 2001 11:01 |
Sundar Venkatasubramaniam
Messages: 26 Registered: May 2001
|
Junior Member |
|
|
first of all you are enclosing b.desc in where clause with quotes it should be
like '%'||b.desc||'%'(any how it ill work for long columns).
for your req you can try this .
Here a.desc and b.desc are long columns
set serveroutput on
declare
cursor c1 is select a.desc adesc ,b.desc bdesc,a.emp_id, b.dept_id from emp a,
dept b where a.dept_id=b.dept_id;
n number;
begin
for c2 in c1
loop
n := instr(c2.adesc,c2.bdesc,1,1);
if n > 0 then
....
end if;
end loop;
end;
/
|
|
|
Re: How do I compare two columns in a two different table that are of type LONG? [message #374120 is a reply to message #374106] |
Fri, 25 May 2001 11:02 |
Sundar Venkatasubramaniam
Messages: 26 Registered: May 2001
|
Junior Member |
|
|
first of all you are enclosing b.desc in where clause with quotes it should be
like '%'||b.desc||'%'(any how it will not work for long columns.in previous reply as usual i made typo error sorry for that.).
for your req you can try this .
Here a.desc and b.desc are long columns
set serveroutput on
declare
cursor c1 is select a.desc adesc ,b.desc bdesc,a.emp_id, b.dept_id from emp a,
dept b where a.dept_id=b.dept_id;
n number;
begin
for c2 in c1
loop
n := instr(c2.adesc,c2.bdesc,1,1);
if n > 0 then
....
end if;
end loop;
end;
/
|
|
|
Re: How do I compare two columns in a two different table that are of type LONG? [message #374126 is a reply to message #374106] |
Fri, 25 May 2001 16:28 |
Khanh Hua
Messages: 7 Registered: May 2001
|
Junior Member |
|
|
Thanks!! I got it to work. One more question. When I am comparing two string with the INSTR function, it checks to see if the string b is in string a. I am running into the problem in that I want sting b to exactly match string a.
Example:
1) INSTR ('ABC Company - Memo text', 'ABC Company', 1,1)
2) INSTR ('ABC Company - Memo text', 'ABC Company - Memo text', 1,1)
I would like only option 2 to return a value greate than zero (i.e. true) Is this possible?
|
|
|
|
|