Skip to content

Instantly share code, notes, and snippets.

@lynnkwong
Last active January 22, 2022 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lynnkwong/3e2c7c48d3152897fbca6d91885c3aea to your computer and use it in GitHub Desktop.
Save lynnkwong/3e2c7c48d3152897fbca6d91885c3aea to your computer and use it in GitHub Desktop.
-- Insert some new records.
INSERT INTO data.product_stocks
(category, stock, check_time)
VALUES
('Laptops', 1313, '2022-01-02 18:00:00'),
('Tablets', 867, '2022-01-02 18:00:00'),
('Cellphones', 5000, '2022-01-02 18:00:00')
ON DUPLICATE KEY UPDATE
stock = VALUES(stock)
;
-- Check records with stock greater than 0.
SELECT * FROM data.product_stocks
WHERE stock > 0
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment