INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Help with SQL

Help with SQL

(OP)
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

 

RE: Help with SQL

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

 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close