Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Joins columns

$
0
0

I have two tables one transaction and other master. 

e.g. 

Transaction table  "Trans" (Receiving, Sending, Dt, tId, pId...)

Receiving Sending  DT         tId   pID

AID     BID     01-01-2019    I1    Q1

QID     CIB     02-02-2019    I2    Q2

PMN     STV    03-02-2019    I3    Q3

Master table has data somthing as below "Master" ( Oid, Oname, ....)

Oid    Oname ....  

AID    AllId_Dept               ......

QID    Qlty_Dept              ......

PMN    Proj_MaintenanceDept              ......

BID     Buss_dept

CIB     Culture_dept

STV    StationeryTools_Dept

Now I have to join the master and transaction table to get more details from master pertaining to the department  for every transaction (e.g. AID, QID..STV)

How I can do this, do I have to join OID of master with Receiving and sending both of Transaction table?

Select t.*, m.oname  from Trans t left join Master m on t.receiving = m.oid and t.sending = m.oid

This is not working, what can be the joining condition?

Thanks,

Neil


Neil



Viewing all articles
Browse latest Browse all 7129

Trending Articles



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