Access SQL Match To Unique Value -


i have 2 different sets of data 2 different sources trying combine create 'pick list' stored in 'sd' table. simple extract of data per below.

the common relationship between 2 sku. sku in sd table gives quantity require pick , can more one. sku in table stock'can have more 1 of same sku each has own unique label id.

sd table:

sku     shoot date 4pycd   14/06/2015 4pyce   14/06/2015 4pycf   14/06/2015 4pycf   14/06/2015 

stock table:

sku id 4pycd   z1234 4pycd   z2345 4pyce   h8767 4pycf   h7890 4pycf   z3456 4pycf   i8976 4pycf   p0989 4pycf   z1236 

for example have 2 sku's required on shoot, , 5 available 'in stock'. need query feed first 2 matched label id's stock table match against sku's requested in pick list table.

desired result:

sku     shoot date  id 4pycd   14/06/2015  z1234 4pyce   14/06/2015  h8767 4pycf   14/06/2015  h7890 4pycf   14/06/2015  z3456 

i have tried play around top function while various subqueries can give me quite need, can ?

current simple sql setup (without attempts of using top):

select tblsd_f4.sku, tblstock.[label no] tblstock right join tblsd_f4 on tblstock.sku = tblsd_f4.sku; 

kind regards

i think looking like:

select top 2 tblsd_f4.sku, tblstock.[label no] tblstock  inner join tblsd_f4  on tblstock.sku = tblsd_f4.sku; 

basically while little rough hand, should give 2 random matching records tblstock table. seems main issue doing right join instead of inner join.

i apologize if syntax off, access spoils me when comes query designing.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -