MySQL - Update/ SELECT c IF Where - пример SQL (условие) + AS + вложенный IF
Primary tabs
Forums:
Пара примеров SQL запросов с использованием оператора IF:
UPDATE:
UPDATE exch_order as eo SET price_per_th = if (eo.price = 0, -2, if(eo.min_work_length = 0, -1, Round(eo.price/eo.min_work_length * 1000))) WHERE customer_id = 312186;
SELECT:
SELECT *, order_name, price, min_work_length, price_per_th, if (eo.price = 0, -2, if(eo.min_work_length = 0, -1, eo.price/eo.min_work_length * 1000)) as term FROM exch_order as eo WHERE customer_id = 312186 ORDER BY (term) DESC;
Посвящаю А.М. =))
- Log in to post comments
- 5346 reads