Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

How to link a table using a command

$
0
0

Hey,

 

This is probably a pretty basic answer for most of you, but it has me stumped! I have two tables which I'd like to link, but the data I'd like to use to link them is split over two fields in one table, but contained in a single field in the other.

 

In one table (called PLINV) there's a single field called INV_NO_LINE - the first 9 numbers contain the invoice number, and the following 3 characters refer to each line of the invoice. So it'll be in the format 123456789001, 123456789002 etc.

 

The other table (called ORDLIN) has two separate fields, one with the invoice number (INV_NO, 9 characters) and one with the line number (INV_LINE, 3 characters). From the ORDLIN table I'd like to fetch a field called NARRATIVE.

 

I'm a bit stuck with what to put as the command. I put the following, but I was a bit confused about what goes in each section (as you can probably see!)

 

SELECT

    ORDLIN.NARRATIVE

FROM

    PLINV LEFT OUTER JOIN ORDLIN ON

    substr(PLINV.INV_NO_LINE,1,9) = ORDLIN.INV_NO AND

    substr(PLINV.INV_NO_LINE,10,3) = ORDLIN.INV_LINE

WHERE

    substr(PLINV.INV_NO_LINE,1,9) = ORDLIN.INV_NO AND

    substr(PLINV.INV_NO_LINE,10,3) = ORDLIN.INV_LINE


Can anyone tell me exactly what I should put in the Command box for this to work? Thank you for any help you can give me.


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>