I have a table of this kind
Table of items with price under 100
| Prod_ID | PRICE |
|---|---|
| 1 | 45 |
| 2 | 67 |
| 3 | 89 |
| 4 | 91 |
| 5 | 23 |
| 6 | 98 |
Now I Want to write PostgresSQL command to update the price of each item increasing it by $10 and want to delete all the items with price more than $100
After the query, the table should be:
| Prod_ID | PRICE |
|---|---|
| 1 | 55 |
| 2 | 77 |
| 3 | 99 |
| 5 | 33 |
How can I do this?
>Solution :
You can use update first and then delete.
UPDATE your_table_name set PRICE=PRICE + 10;
DELETE FROM your_table_name WHERE PRICE > 100;