• drew.allen (5/27/2016)


    Looking at your queries, it looks like you may not realize that you can join to the same table multiple times as long as they have different aliases.

    SELECT *

    FROM Join_Details j

    INNER JOIN Lookup_C AS g --gender

    ON j.Gender_FK = g.lc_pk

    INNER JOIN Lookup_C AS s --style

    ON j.Style_FK = s.lc_pk

    Drew

    Thank You very much for your explanation!

    Following your advice, I made some adjustments on the code and this is how it looks now!

    SELECT

    i.ITEMS_PK as 'SKU 1',

    i.INVNUM as 'SKU 2',

    i.OWNERNUM as 'Online SKU',

    i.NEWITEM as 'Condition',

    T.lc_Descript as 'Condition 2',

    i.STATUS as 'Status',

    i.BIN as 'Location',

    k.DESCRIPT as 'Online Status',

    h.DESCRIPT as 'Brand',

    i.MODELNUM as 'Reference #',

    i.SERIALNUM as 'Serial #',

    l.DESCRIPT as 'Model Name',

    c.lc_Descript as 'Dial Color',

    i.AMOUNT as 'Cost',

    M.lc_Descript as 'Case Material',

    b.lc_Descript as 'Bracelet Material',

    S.lc_Descript as 'Bezel Type',

    g.lc_Descript as 'Gender',

    j.Weight as 'Weight',

    z.lc_Descript as 'B Size',

    i.DESCRIPT as 'Item Description',

    i.CSOURCE as 'Seller'

    FROM items as I

    inner join Detail_J as J

    on I.ITEMS_PK = J.Items_FK

    inner join Level3 as L

    on I.LEVEL3_FK = L.lv3_pk

    inner join Level4 as K

    on I.LEVEL4_FK = K.lv4_PK

    inner join Level5 as H

    on I.LEVEL5_FK = H.lv5_PK

    inner join Lookup_C as C

    on I.Color = C.lc_pk

    inner join Lookup_C as T

    on I.Condition = T.lc_pk

    INNER JOIN Lookup_C AS G --gender

    ON j.Gender_FK = G.lc_pk

    INNER JOIN Lookup_C AS S --Bezel

    ON j.Style_FK = S.lc_pk

    inner join Lookup_C as B ---bracelet material

    on J.Karat_FK = B.lc_pk

    inner join Lookup_C as Z ----bracelet Size

    on J.Sizelen_FK = Z.lc_pk

    inner join Lookup_C as M ---- Case Material

    on J.Metal_FK = M.lc_pk

    order by J.Items_FK

    I am finally getting the DATA I need, in ONE single report!!!:-D

    Happy Weekend!