• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1295
  • Last Modified:

SQL Question - Varchar and Char type join

Hi all.  I am attempting to perform a join in a SQL statement of varchar and char on 2 different tables based in an Oracle DB.  The field name is "Serl_Nbr" in both tables.  Granted, I'd like to correct the issue in the DB, but this is somewhat of a lost cause as I am not the DBA and do not feel comfortable generating such a change on a whim.  Thanks in advance.
1 Solution
Nick UpsonPrincipal Operations EngineerCommented:
select ....
from tablea a
join tableb b on trim(a.Serl_Nbr) = trim(b.Serl_Nbr)
where ...
Jinesh KamdarCommented:
SELECT A.col, B.col FROM table1 A, table2 B WHERE TRIM(a.serl_nbr) = TRIM(b.serl_nbr);

>> I am not the DBA and do not feel comfortable generating such a change on a whim.

You need *NOT* be a DBA to make such decisions as defining a NUMERIC PK id for ur tables. If the table-design is in ur hands, then u can definitely enforce to change its structure to a more realistic design and ur DBA will be more than happy to do it for u since he realises that doing it will ultimately increase the peformance and reduce his head-ache too.
David ToddSenior DBACommented:

Depending on the dialect of SQL that you are using, the function you are looking for code be rtrim( ).

smagnus1Author Commented:
I truely do wish I could convince the powers that be to change this field type, but it is a "one man versus the world" type thing.  This did work, although my query is not really any faster.  I am thinking maybe a subquery, but I haven't pulled this off as of yet.  Thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now