473,472 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SQL Query - Explain please

47 New Member
--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 944

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

Similar topics

4
by: DBNovice | last post by:
I have a database that keeps records on the issue and failure of an item. Currently, the database is poorly desisned; therefore I'm performing queries to break the data into normalized tables and...
6
by: Bruce D | last post by:
Could someone please help to explain why the following query isn't using the index... explain select id from kbm where state = 'MA' table type possible_keys key key_len ref rows Extra...
4
by: jimh | last post by:
I'm not a SQL expert. I want to be able to write a stored procedure that will return 'people who bought this product also bought this...'. I have a user table that links to a transaction table...
6
by: Uros | last post by:
Hello! I have some trouble getting good results from my query. here is structure stat_views id | integer id_zone | integer created | timestamp
5
by: sgdbprog1 | last post by:
Please can someone help me with the following question. Using mainframe db2 ie on MVS OS/390 for a select against a single table will db2 use mutiple indexes? ex: select * from table1 where...
21
by: CSN | last post by:
I have a pretty simple select query that joins a table (p) with 125K rows with another table (pc) with almost one million rows: select p.* from product_categories pc inner join products p on...
2
by: Zygo Blaxell | last post by:
I have a table with a few million rows of temperature data keyed by timestamp. I want to group these rows by timestamp intervals (e.g. every 32 seconds), compute aggregate functions on the...
16
by: Sam Durai | last post by:
Hello, I need to merge a small table (of rows less than 100,sometimes even 0 rows) to a big table (of rows around 4 billion). I used the PK of the big table as merge key but merge does a table scan...
7
by: skaushik | last post by:
Hi all, I was working on a SQL query where a history table is joined with a small table to get some information. There is an index on the history table column but the explain plan tells that there...
2
by: uwcssa | last post by:
is there a way to see the actual (not just estimated) cost and cardinality at each plan operator? SQL Server and Oracle has such feature but I failed to find a way in DB2 yet (up to V9.5)
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.