how to do DB update with limit

Hi All,

I just wanna do an update {table} set {field} = {value} where {condition} LIMIT 10


If I use like this, it will update all the record meeting the condition, I dont wanna update all records only a few  by specifying limit

Thnx in advance

See here: instead of a condition you can also supply a CDbCriteria and use its limit property.

Its got resolved. But its not working the way as I expected.

What it doing is,

      if the limit is 10, its looking the first 10 record which satisfy the condition and update those records.

I just want how exactly 'update with limit' work in mysql

Doesn't this work?


$c=new CDbCriteria;




Post::model()->updateAll($a, $c);

You can also turn on logging e.g. with CWebLogRoute and look at the created SQL to maybe find out what's wrong.

it worked  :D Thnx Mike