28/04/2024 | 21:37
F88 có cầm giấy tờ xe không? F88 cầm đăng ký xe máy ôtô
Sure, you can use the following SQL query to add a "status" column to an orders table and set it to default to 'PENDING', but if the 'completed_at' column is set, it will be set to 'COMPLETE':
```sql
ALTER TABLE orders
ADD COLUMN status VARCHAR(10) DEFAULT 'PENDING';
UPDATE orders
SET status = 'COMPLETE'
WHERE completed_at IS NOT NULL;
```
This assumes that your table is named 'orders', the status column is of type VARCHAR(10), and 'completed_at' is the column that indicates when an order is completed. Adjust the column types and names as per your schema.
4.9/5 (93 votes)
Có thể bạn quan tâm:
Website