Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing Names [with space and without space] 1

Status
Not open for further replies.

acct98

IS-IT--Management
Aug 15, 2002
194
US
I have two tables:
TABLE A TABLE B
SSN 123456789 SSN 123456789
NAME DOE, JOHN VNAME DOE,JOHN

I would like to seleced all records from both tables where the SSN & NAME are the same. However, in the example above there is a space between the last name and first name in TABLE A and no space between the last name and first name in TABLE B. Is there a simple way to compare the names?
 
Acct,

You have multiple options available to you to resolve your need. One method is to get rid of just a blank space that follows a comma:
Code:
select 'These are equal' from dual
where replace('DOE, JOHN',', ',',') = replace ('DOE,JOHN',', ',',');

'THESEAREEQUAL'
---------------
These are equal

...or eliminate all blanks spaces altogether:
Code:
select 'These are equal' from dual
where translate('DOE, JOHN','^ ','^') = translate('DOE,JOHN','^ ','^')

'THESEAREEQUAL'
---------------
These are equal

Let us know if either of these methods please you.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 18:46 (26Jul04) UTC (aka "GMT" and "Zulu"), 11:46 (26Jul04) Mountain Time)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top