Reply to Re: Inner Join Problem

Your name:

Reply:


Posted by Ed Murphy on 12/17/06 16:37

info@bodykind.com wrote:

> The following query appears to work correctly in SQL server, the only
> problem (and it is a major problem) is that it sets the value of the
> stock field to null on every record except the one that it is reducing.
>
> Any ideas?
>
> ----------------------------------------------------------------------------------------------------
> UPDATE Products
>
> SET Products.Stock = Products.Stock -
>
> (
> select sum(OrdersProducts.Quantity)
> from OrdersProducts
> where ordersproducts.ProductID=products.ProductID and
> ordersproducts.orderid = 63116 group by ordersproducts.ProductID
> )
>
> FROM Products

Change
sum(OrdersProducts.Quantity)
to
coalesce(sum(OrdersProducts.Quantity),0)

Alternatively, append the WHERE EXISTS portion of Gert-Jan's query.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация