Solved

Sql Query Value formatting join problem

Posted on 2013-11-12
10
384 Views
Last Modified: 2013-11-12
Hi

This one should be simple enough to answer but I can not see the problem..

I try to do an inline select based on a value.

Select b.column1, (select a.description from aTable a where a.column1=b.column1)
from bTable.

My inline query returns a null even though the column1 from both tables looks the same to me in each row.
The b.column1 is defined as nvarchar2(20)
The a.column1 is defined as varchar2(255 bite)

The b.column1 was imported from tabbed delimited text file using ssis.

Is there someone who can advise me on how to proceed?
0
Comment
Question by:devguru001
10 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 39641028
try to use Trim on bothe the fields in comparision
0
 
LVL 13

Expert Comment

by:Alexander Eßer [Alex140181]
ID: 39641030
Have you checked for leading and/or trailing spaces in both columns?!
Maybe you could try to trim both?!?
0
 

Author Comment

by:devguru001
ID: 39641039
Hi, I tried the sql trim statement and it did not help.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39641048
use an upper trim ?

Select b.column1, (select a.description from aTable a where upper(trim(a.column1)) =upper(trim(b.column1)))
from bTable.
0
 

Author Comment

by:devguru001
ID: 39641053
Hi
The value in both columns looks like 'WYB'. When I hard code this value to replace a.column1 I get my desired result. When I use a.Column1 I get nothing.
I am using TOAD for Oracle and can not see a reason, I also thought it should be a trim issue but it is not helping, converting to upper did not help either, upon inspection it was also obvious that the case was not the issue.
0
 

Author Comment

by:devguru001
ID: 39641055
Does anyone know of a way that I can analyse each value somehow to see how they differ in formatting etc?
0
 
LVL 37

Accepted Solution

by:
Geert Gruwez earned 500 total points
ID: 39641057
yeah, use dump to see the characters

Select dump(b.column1) from bTable b

select dump(a.column1) from atable a
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39641060
possible you need a to_char on both :

Select b.column1, (select a.description from aTable a where to_char(a.column1)=to_char(b.column1))
from bTable.
0
 

Author Comment

by:devguru001
ID: 39641202
Hi Geert,

The dump statement let me see that there were tabs and spaces included in the string of a.column1. If I remove those my query will be solved, as such you win the grand prize :)

Thanks everyone for your time and suggestions.
0
 

Author Comment

by:devguru001
ID: 39641224
If anyone is interested, this is the code which removed tabs and spaces etc:

regexp_replace(a.column1, '[[:space:]]',null)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to return an OUT parameter from and ORACLE 3 66
Oracle SQL 6 57
Oracle SQL syntax check  without executing 6 50
Oracle SQL Select unique values from two columns 4 52
Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question