Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Adopt a JSR - Mailing Lists

brjavamanOct 12 2015

Patenschaft f?r ein JSR


1 messages | 27 subscribers



Issues Mailing List


12 messages | 99 subscribers



Adopt a JSR

1351 messages | 291 subscribers



Adote uma JSR - Portugues


271 messages | 168 subscribers

Comments

Gaz in Oz

Your update syntax suggests you are working with MYSQL db.

It always helps to format your code into a more readable and maintainable style, for example:

Update products,

       orderdetails,

       orders

set    products.UnitsInStock = (products.UnitsInStock - orderdetails.Quantity),

       ShippedDate = current_date()

where  products.ProductID = orderdetails.ProductID

and    orders.OrderID = orderdetails.OrderID

and   (ShippedDate is null and

       orderdetails.Quantity < UnitsInStock)

and    orders.OrderID  = 11039;

The fact the update is updating rows you don't want it to means you haven't got the join to the three tables correct.

Write it as a select statement first then convert it into an update when you are sure it will update the rows you want it to.

...and as this looks like a mysql question you be better off asking your question here or

here http://forums.mysql.com/

John Thorton

Gayathri Venugopal wrote:

Hi, I need to update UnitinStock and Shipped Date of products based on these conditions.

1)When the shipped date is null and

2) when Quantity < Unit in stock.

But my query is updating Shipped date of all the orders even when this condition Quantity < Unit in stock is not satisfied .

How do I satisfy these 2 conditions and update colums:

Update products,orderdetails,orders

set products.UnitsInStock = (products.UnitsInStock - orderdetails.Quantity), ShippedDate = current_date()

where products.ProductID =orderdetails .ProductID and orders.OrderID = orderdetails.OrderID

and (ShippedDate is null and orderdetails.Quantity < UnitsInStock) and orders.OrderID = 11039

Please click on URL below & provide details as stated in #5 - #9 inclusive

How do I ask a question on the forums?

Please post full results from SQL below

SELECT * FROM V$VERSION;

mathguy

You were told two days ago, in a different thread you started, that this is NOT A MySQL FORUM.   Repeat:  This is NOT A MySQL FORUM.  Is that hard to understand?

Timo Hahn

***Moderator action (Timo): User, I moved you thread to the MySql space as it isn't about OracleDB.***

1 - 4

Post Details

Added on Oct 12 2015
0 comments
497 views