Certainly! Let's say you run a bookstore and you want to update the price of the book 'The Great Gatsby' because it's currently out of stock and you're planning to order a new edition that costs more. Here's how you could use the SQL UPDATE
statement to change the price in your Books
table:
UPDATE Books
SET Price = 12.99, InStock = TRUE
WHERE BookID = 3;
This code will set the price of 'The Great Gatsby' to $12.99 and update its stock status to TRUE
, indicating that it's back in stock. Remember to replace table_name
, column1
, value1
, etc., with the actual table name and column names/values you're working with in your database.
Top comments (1)
Hey, this article appears to have been generated with the assistance of ChatGPT or possibly some other AI tool.
We allow our community members to use AI assistance when writing articles as long as they abide by our guidelines. Please review the guidelines and edit your post to add a disclaimer.
Failure to follow these guidelines could result in DEV admin lowering the score of your post, making it less visible to the rest of the community. Or, if upon review we find this post to be particularly harmful, we may decide to unpublish it completely.
We hope you understand and take care to follow our guidelines going forward!