I am not very experienced with SQL but I have put together a query that I though should update two prices in one table (to add on 20% tax) using the description in another table by joining the tables, here is my problem code:-
UPDATE IT_PRICE
SET ITPrice1 = Price1 + (Price1 * .2), ITPrice2 = Price2 + (Price2 * .2)
INNER JOIN IT_PRICE
ON ITEMS.ID = IT_PRICE.ID
Where ITPrice1 <= 0 AND ITPrice2 <=0 AND ITEMS.Item = 'Jet Tec HP 78'
I have tried this in SQL Express 2008 and full SQL 2012 but I get a syntax error on 'INNER' so I tried to hit it from a different angle by using a WITH statement:-
WITH Item_ID as (
SELECT ITEMS.ID FROM ITEMS WHERE ITEMS.Item = 'Jet Tec HP 78'
)
UPDATE IT_PRICE
SET ITPrice1 = Price1 + (Price1 * .2), ITPrice2 = Price2 + (Price2 * .2)
WHERE ITPrice1 <= 0 AND ITPrice2 <=0 AND ID = Item_ID
And now I get 'Invalid column name Item_ID' when I execute the statement. All I want to do is add tax onto two prices in the IT_PRICE table to all items in ITEMS where I match the description.
If anyone can point me in the right direction it would be very much appreciated.
Thanks.