troubleshooting Question

SQL SUBSTR Syntax with Creating a Join

Avatar of Derek_Indianapolis
Derek_Indianapolis asked on
13 Comments1 Solution2383 ViewsLast Modified:
I have an SQL requiring an inner join.  The hitch is for table A the join condition (ON clause) is part of a string.  Specifically I want to make a join looking similar to this...

"from table1  inner join  table2 on table1.ordernum = substr(table2.ordertrans,1,10)"

I can not get the syntax to work.  To explain a little further into what I was attempting to do in the example...
Within a string of text in table2 you can find table1.ordernum.  The string is the first 10 characters which will make the join, the rest of the characters after 10 are not useful in this situation.

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros