|
Posted by Erland Sommarskog on 11/17/05 01:07
diablo (diablo@noplace.com) writes:
> However the issue still remains that Jens code gives a syntax error
> missing operator: 'quantity - c.quantity FROM product p ...'
Then use the syntax David posted first:
UPDATE product
SET quantity = quantity -
(SELECT SUM(quantity)
FROM cart
WHERE cart.buyerid = x
AND cart.productid = product.productid)
WHERE EXISTS
(SELECT *
FROM cart
WHERE cart.buyerid = x
AND cart.productid = product.productid) ;
The syntax Jens posted works on Microsoft SQL Server, which is what we
discuss in this newsgroup. But judging from the error message you are
using some other product, unknown which. You may getter better help
if you ask in a forum for that product.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|