Re: update option to alter only 1 row?
On Thu, 07 Feb 2008 02:23:27 +0100, Rik Wasmus
<luiheidsgoeroe@hotmail.com> wrote:
> On Wed, 06 Feb 2008 22:59:16 +0100, Jeff <no_one@george.com> wrote:
>
>>
>> "Andreas Stieger" <Andreas.Stieger@gmx.de> wrote in message
>> news:47a96974$0$9109$9b4e6d93@newsspool2.arcor-online.net...
>>> Hi,
>>>
>>> Jeff wrote:
>>>
>>>> I just want 1 of them changed to 3 and it doesn't matter which.
>>>
>>> ...LIMIT 1
>>
>> ...still not working. The first query below does not work (mysql 5.22)
>> with
>> the alter command, but the second does with select. Any ideas?
>>
>>
>> alter mytable set QN = 2 where QN = 3 limit 1; ** doesn't work **
>>
>> select QN from mytable where QN = 3 limit 1; ** does work **
>
> Euhm, UPDATE statement, not ALTER....
>
> UPDATE `mytable` SET `QN` = 2 WHERE `QN` = 3 LIMIT 1;
Oh, and for a more random row to be altered:
UPDATE `mytable` SET `QN` = 2 WHERE `QN` = 3 ORDER BY RAND() LIMIT 1;
see: <http://dev.mysql.com/doc/refman/5.1/en/update.html>
--
Rik Wasmus
|