*sigh* Can someone explain to me where I'm going wrong here. :( Basically its an order system. Products have Colours and electrical specs which define the voltage. Distributors have access to certain Products. I need to find all of the Products in a certain category. Now when you make an Order, an entry is put into OrdProd (a copy of the price, prod id and quantity etc). This means prices can change over time and not effect older orders. Obviously not all Products have been ordered, so there may not be a row in OrdProd...so for this I need a Left join on OrdProd yeah?
Atm the page is alittle slow loading so I was hoping I could cut out these two sub queries to improve performance abit (this query can return 100 odd rows in a single hit or can sometimes be run multiple times for about 10 rows each). I dunno, performance on my lowly little Macbook isn't too bad, but on the server it can be quite a few seconds so perhaps its entirely a server issue.
So, the SQL,
SELECT PROD_ID, DISTPROD_PRODNAME, PROD_EXTRA, COL_NAME, COL_RGBHEX, VOLT_NAME, DISTPROD_PRICE,
isnull((SELECT ORDPROD_QUANTITY FROM ORDPROD WHERE ORDPROD_PROD_ID = PRODUCT.PROD_ID AND ORDPROD_ORD_ID = @OrdID), 0) AS QUANTITY,
isnull((SELECT ORDPROD_PRICE FROM ORDPROD WHERE ORDPROD_PROD_ID = PRODUCT.PROD_ID AND ORDPROD_ORD_ID = @OrdID), 0) AS ORDPROD_PRICE
FROM PRODUCT, DISTPAGE, DISTPROD, COLOUR, VOLTAGE, ELECTSPEC
WHERE DISTPAGE_DIST_ID = @DistID AND DISTPAGE_CAT_ID = PROD_CAT_ID
AND PROD_CAT_ID = @CatID
AND DISTPROD_DIST_ID = DISTPAGE_DIST_ID
AND DISTPROD_PROD_ID = PROD_ID
AND DISTPROD_STATUS = 'ACTIVE'
AND PROD_COL_ID = COL_ID AND PROD_ELECTSPEC_ID = ELECTSPEC_ID
AND ELECTSPEC_VOLT_ID = VOLT_ID
ORDER BY DISTPROD_PRODNAME
if I replace the top few lines with this,
SELECT PROD_ID, DISTPROD_PRODNAME, PROD_EXTRA, COL_NAME, COL_RGBHEX, VOLT_NAME, DISTPROD_PRICE
FROM PRODUCT, DISTPAGE, DISTPROD, COLOUR, VOLTAGE, ELECTSPEC
LEFT JOIN ORDPROD ON PROD_ID = ORDPROD_PROD_ID
SQL Express says,
Msg 207, Level 16, State 1, Line 4
Invalid column name 'PROD_ID'.
Am I making some noob mistake?
If I do PRODUCT.PROD_ID I get
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "PRODUCT.PROD_ID" could not be bound.
That’s not quite right. It’s not rdping into a Windows machine to use apps. This had existed in the past as RemoteApp where just the virtualized app(s) is/are presented to the user and not a full vm.
https://remoteapp.readthedocs.io/en/stable/remoteapp-anyapp/
Im guessing they just made the process easier now and are treating what they killed off as something new.
Question
Pc_Madness
*sigh* Can someone explain to me where I'm going wrong here. :( Basically its an order system. Products have Colours and electrical specs which define the voltage. Distributors have access to certain Products. I need to find all of the Products in a certain category. Now when you make an Order, an entry is put into OrdProd (a copy of the price, prod id and quantity etc). This means prices can change over time and not effect older orders. Obviously not all Products have been ordered, so there may not be a row in OrdProd...so for this I need a Left join on OrdProd yeah?
Atm the page is alittle slow loading so I was hoping I could cut out these two sub queries to improve performance abit (this query can return 100 odd rows in a single hit or can sometimes be run multiple times for about 10 rows each). I dunno, performance on my lowly little Macbook isn't too bad, but on the server it can be quite a few seconds so perhaps its entirely a server issue.
So, the SQL,
if I replace the top few lines with this,
SQL Express says,
Msg 207, Level 16, State 1, Line 4
Invalid column name 'PROD_ID'.
Am I making some noob mistake?
If I do PRODUCT.PROD_ID I get
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "PRODUCT.PROD_ID" could not be bound.
*grumble* Any ideas?
Link to comment
https://www.neowin.net/forum/topic/672492-sql-help-with-left-joins/Share on other sites
8 answers to this question
Recommended Posts