470,596 Members | 1,573 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,596 developers. It's quick & easy.

SQL Query - Explain please

--The UPDATE statement is used to modify the data in the AVTTB_PRODUCT_UDA Table.
UPDATE AVTTB_PRODUCT_UDA
SET
--The PRU's are from AVTTB_PRODUCT_UDA
--and they are being updated to values from the V_APOLLO_PRODUCT View.
PRU_VALUE1 = XXX.USERDESCA,
PRU_VALUE2 = XXX.USERDESCC,
PRU_VALUE3 = NULL,
PRU_VALUE4 = XXX.PLOTDESC2,
PRU_VALUE5 = XXX.SUBCATEGORY,
PRU_VALUE6 = XXX.SKU,
PRU_VALUE7 = XXX.XPEGHOLE,
PRU_VALUE8 = XXX.YPEGHOLE,
PRU_VALUE9 = XXX.CIC,
PRU_VALUE10 = XXX.NUM1,
PRU_VALUE11 = XXX.NUM2,
PRU_VALUE12 = XXX.NUM3,
PRU_VALUE13 = XXX.TEXT1,
PRU_VALUE14 = XXX.TEXT2,
PRU_VALUE15 = XXX.TEXT3
FROM AVTTB_PRODUCT_UDA PRU, --and a temp table made of the following...
(
--Selecting distinct values from V_APOLLO_PRODUCT and AVTTB_PRODUCT_DEF
SELECT DISTINCT VPR.UPC, VPR.STOCKCODE, VPR.USERDESCA, VPR.USERDESCC, VPR.PLOTDESC2,
VPR.SUBCATEGORY, VPR.SKU, VPR.XPEGHOLE, VPR.YPEGHOLE, VPR.CIC, VPR.NUM1, VPR.NUM2, VPR.NUM3,
VPR.TEXT1, VPR.TEXT2, VPR.TEXT3, PRD1.PRD_ID, PRD1.PRD_CODE, PRD1.PRD_UPC, PRD1.PRD_CLIENT_ID

FROM V_APOLLO_PRODUCT VPR
--The INNER JOIN returns all rows from both tables where there is a match.

--Join V_APOLLO_PRODUCT to AVTTB_PLANO Where the SectionID's Match
INNER JOIN AVTTB_PLANO POG ON VPR.SECTIONID = POG.POG_CLIENT_CODE

--Join V_APOLLO_PRODUCT to AVTTB_PRODUCT where the POG_ID's match
INNER JOIN AVTTB_POG_PRODUCT PPR ON POG.POG_ID = PPR.POG_ID

--Join V_APOLLO_PRODUCT ON AVTTB_PRODUCT_DEF where the PRD_ID's match
INNER JOIN AVTTB_PRODUCT_DEF PRD ON PPR.PRD_ID = PRD.PRD_ID

--Join V_APOLLO_PRODUCT ON AVTTB_PRODUCT_DEF where the PRD_PID's Match
INNER JOIN AVTTB_PRODUCT_DEF PRD1 ON PRD.PRD_PID = PRD1.PRD_ID

--Join V_APOLLO_PRODUCT ON AVTTB_PRODUCT_UDA where the PRD_ID's match
INNER JOIN AVTTB_PRODUCT_UDA PRU ON PRD1.PRD_ID = PRU.PRD_ID

--Select the above where AVTTB_PRODUCT_DEF.PRD_UPC = V_APOLLO_PRODUCT.UPC
WHERE PRD.PRD_UPC = VPR.UPC

--AND AVTTB_PRODUCT_DEF.CLIENT_ID = V_APOLLO_PRODUCT.STOCKCODE
AND PRD.PRD_CLIENT_ID = VPR.STOCKCODE

--AND AVTTB_PRODUCT_UDA.PRD_ID = -3
AND PRD1.PRT_ID =-3

--AND AVTTB_PRODUCT_UDA.PRT_ID = -4
AND PRD.PRT_ID =-4)XXX


--Do all of the above where the AVTTB_PRODUCT_UDA.PRD_ID = V_APOLLO_PRODUCT.PRD_ID match
WHERE PRU.PRD_ID = XXX.PRD_ID
GO


Could someone plese give me a rundown on what they think is happening here... I am fairly new to this. Thank You to all who can help!
Jun 29 '07 #1
0 905

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by DBNovice | last post: by
6 posts views Thread by Bruce D | last post: by
4 posts views Thread by jimh | last post: by
6 posts views Thread by Uros | last post: by
5 posts views Thread by sgdbprog1 | last post: by
16 posts views Thread by Sam Durai | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.