02/05/2024 | 12:36
Happy Money Nguyễn Văn Cừ Long Biên Hà Nội vay tiền cavet nhanh
Sure, here's a SQL query to add a "status" column to an existing "orders" table:
```sql
ALTER TABLE orders
ADD COLUMN status VARCHAR(20) DEFAULT 'PENDING';
UPDATE orders
SET status = 'COMPLETE'
WHERE completed_at IS NOT NULL;
```
This query first adds a new column named "status" to the "orders" table with a default value of 'PENDING'. Then it updates the "status" column to 'COMPLETE' for those orders where the "completed_at" column is not null.
4.9/5 (47 votes)
Website