I want to update a row in my date base. The problem is, through a mistake on my part, I have two identical rows of data. How do I run the update on just one row?
To update an entire row in MySQL, use UPDATE command. You need to know the primary key column. The syntax is as follows to update an entire row. The following is the query to update an entire row in MySQL.
In SQL Server 2005+, you can use
UPDATE TOP (1) ....
The advantage of this over SET ROWCOUNT
is that any triggers will not be subject to a ROWCOUNT
limit, which is almost certainly a good thing.
Often tables have a unique ID. And you should filter on that.
For example,
UPDATE YourTable
SET YourColumnToUpdate = 'your_value'
WHERE YourUniqueColumn = @Id
If your table does not have a unique ID, consider adding one: an integer
column with a Primary Key
and Identity
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With