Курсовая работа: База данных "фруктовый сад"
WHERE ID_selling = (SELECT MAX (ID_selling) FROM selling);
Запрос на обновление товара (добавление):
INSERT INTO shelfs (ID_product, price, quantity)
SELECT ID_product, price, (SELECT shelfs. quantity-selling. quantity AS quantity FROM shelfs INNER JOIN selling ON shelfs. ID_shelf=selling. ID_shelf WHERE selling. ID_selling = (SELECT MAX (ID_selling) FROM selling))
FROM shelfs
WHERE ID_shelf = (SELECT ID_shelf FROM selling WHERE ID_selling = (SELECT MAX (ID_selling) FROM selling));
Запрос на обновление товара (удаление):
DELETE *
FROM shelfs
WHERE ID_shelf = (SELECT ID_shelf FROM selling WHERE ID_selling = (SELECT MAX (ID_selling) FROM selling));
Запрос на откат продажи:
DELETE *
FROM selling
WHERE ID_selling = (SELECT MAX (ID_selling) FROM selling);
Запрос на покупку товара:
INSERT INTO shelfs (ID_product, quantity, price)
SELECT ID_product, quantity, sum
FROM buying
WHERE ID_buying =
(SELECT MAX (ID_buying) FROM buying);
Запрос на удаление товара:
DELETE *
FROM shelfs
WHERE ID_shelf = (SELECT ID_shelf FROM selling WHERE ID_selling = (SELECT MAX (ID_selling) FROM selling));
Запрос на удаление старой продажи:
DELETE *
FROM selling
WHERE ID_selling = (SELECT MAX (ID_selling) - 1 FROM selling);
Почти все эти запросы можно увидеть на главной форме в виде таблиц при нажатии кнопки.