You want to update all orders with location DRS and sta_enable = 0. One table to update, two conditions in the WHERE
clause:
update orders o
set o.ords_stas_id = 23
where o.location = 'DRS'
and o.order_status_id in (select s.status_id from status s where s.stas_enable = 0);
Just in order to mention it: Sometimes we do have a query the joins of which both lead to the rows to update and the value to set. In that case we apply the update on the query. (This is not the case in your statement, though; we already know that we must set the id to 23. It would be the case if we got the id to set in the order table from the status table row.)
We could write your update statement thus:
update
(
select ords_stas_id as value, 23 as new_value
from orders o
inner join status s on o.order_status_id = s.status_id
set o.ords_stas_id = '23'
where o.location = 'DRS'
and s.stas_enable = 0
)
set value = new_value;
which would do the same thing as my query above, only in a more complicated way. But if we wanted to use a value from the status table, e.g. replace 23 as new_value
by s.some_id as new_value
, then this would be the appropriate way to write the update statement.