MySQL Forums
Forum List  »  Newbie

Re: Simple question about UPDATE syntax
Posted by: Roland Bouman
Date: July 31, 2005 12:00PM

johansontag wrote:
> Just a quick and simple question:
>
> What if I use UPDATE blablabla WHERE blablabla but
> there actually isnĀ“t a row in the table that

No it executes the update, but it just happens to apply to no row. So, there is no change in the data after execution of the statement.

> Also if i use the same syntax and there is a lot
> of records that fit the WHERE statement, how can I
> limit it so that it only updates one row?

UPDATE blablab
WHERE blablab
LIMIT 1

However, the one rows that will be updated will be whatever is the first row. So generally, there something wrong when you need to resort to this mechanism for an update.

FOr SELECT statements, the ;limit is quite often used to create some pagination mechanism in web pages. There it does make sense.

Options: ReplyQuote


Subject
Written By
Posted
Re: Simple question about UPDATE syntax
July 31, 2005 12:00PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.