Jeniferous
IS-IT--Management
I want to set a status field to P where a condition is met in an alternative table. The alternative table contains order lines but there could be more than one order line per order number but the table i'm updating has a single record per order. I've got the below code....
UPDATE OrderHeader
SET orderheader.[status]='P'
from orderheader inner join orderlines on orderheader.ordernumber= orderlines .ordernumber
WHERE orderlines.order_qty = orderlines.despatched_qty
If i run it then I don't get errors but it changes the status to P if the first instance of the order in the lines table meets the criteria. I want it to set it to P if ALL the records for that order within the lines table meet the criteria and set it to E if any don't!
Can someone help me! Hope that makes sense!
P.s. i'm a newbie to sql so keep it basic please!
UPDATE OrderHeader
SET orderheader.[status]='P'
from orderheader inner join orderlines on orderheader.ordernumber= orderlines .ordernumber
WHERE orderlines.order_qty = orderlines.despatched_qty
If i run it then I don't get errors but it changes the status to P if the first instance of the order in the lines table meets the criteria. I want it to set it to P if ALL the records for that order within the lines table meet the criteria and set it to E if any don't!
Can someone help me! Hope that makes sense!
P.s. i'm a newbie to sql so keep it basic please!