Kim ngưu vay online app apk h5
Certainly! You can use the following SQL query to add a "status" column to an existing "orders" table:
```sql
ALTER TABLE orders
ADD COLUMN status VARCHAR(20) DEFAULT 'PENDING';
```
This query adds a new column named "status" to the "orders" table with a default value of 'PENDING' for all existing rows.
To update the status to 'COMPLETE' if "completed_at" is set, you can use the following query:
```sql
UPDATE orders
SET status = 'COMPLETE'
WHERE completed_at IS NOT NULL;
```
This query updates the "status" column to 'COMPLETE' for rows where the "completed_at" column is not null, indicating that the order has been completed.
4.8/5 (95 votes)
Có thể bạn quan tâm: