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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with SQL

Status
Not open for further replies.

masha2008

Technical User
Nov 12, 2008
4
US
Im making a Join

Code:
Select Table1
      
   From Tables

  Where Table1=Table2

Table1   Table2
09876    Q9876
09871    Q9871
02345    Q2345
09867    Q9867

I need to join these two tables, and pull Table1, however I still need for that letter Q to be equal to '0' and I need to keep the zero in front of the number..

Im trying to use REPLACE
Code:
 SELECT Table1, 
       Table2,

FROM  ACCT_HIST left join
         ACCT_LIST on (Table1 = replace table2 ,'Q','0' left join
I keep getting this error expected something between = and REPLACE.

What am I doing wrong?

Thank you

 
Would something like this work for you?

Code:
SELECT table1
FROM ACCT_HIST a
            ,ACCT_LIST  b
WHERE SUBSTR(TRIM(table1), 2, LENGTH(TRIM(table1))-1) = SUBSTR(TRIM(table2), 2, LENGTH(TRIM(table2))-1)

Results:

table1
09871
09876
02345
09867

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top