Back to Browse

8. How to Update the column value based on certain condition in SQL

490 views
Mar 8, 2025
7:53

CREATE TABLE orders ( order_id INT PRIMARY KEY, customer_name VARCHAR(100), order_date DATE, status VARCHAR(20) ); INSERT INTO orders (order_id, customer_name, order_date, status) VALUES (1, 'John Doe', '2025-01-15', 'Pending'), (2, 'Jane Smith', '2025-02-20', 'Completed'), (3, 'Mark Brown', '2025-01-10', 'Pending'), (4, 'Lisa Green', '2025-03-05', 'Shipped'), (5, 'Adam White', '2025-01-25', 'Pending'), (6, 'Emma Black', '2025-02-15', 'Pending'); select * from orders UPDATE orders SET status= 'Overdue' WHERE STATUS='Pending' and DATEDIFF(DAY,order_date,GETUTCDATE())

Download

1 formats

Video Formats

360pmp46.2 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

8. How to Update the column value based on certain condition in SQL | NatokHD