The query below is working:
update top(1) ShipBillInfo set shipfirstname='kkk' where CustomerId='134';
but it is showing error if i try to order by some Id: for example:
update top(1) ShipBillInfo set shipfirstname='kkk' where CustomerId='134' order by OredrGUID desc;
UPDATE TOP (100) table_name set column_name = value; If you want to show the last 100 records, you can use this if you need. Show activity on this post. The TOP qualifier can also be used as limit the the number of rows manually updated incorrectly.
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 SQL SELECT TOP ClauseThe SELECT TOP clause is used to specify the number of records to return. The SELECT TOP clause is useful on large tables with thousands of records. Returning a large number of records can impact performance. Note: Not all database systems support the SELECT TOP clause.
With cte as ( select top(1) shipfirtsname From ShipBillInfo where CustomerId='134' order by OredrGUID desc) Update cte set shipfirstname='abc';
why dont you do :
update ShipBillInfo set shipfirstname='kkk' where OrderGUID = (select top (1) OrderGUID from ShipBillInfo where CustomerId = 134 order by OredrGUID desc )
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