Shaun Mccran

My digital playground

14
J
A
N
2009

Using LIMIT in mySql Update script

I've recently switched to MySql, as my present employer uses it.

Its taken a bit of getting used to, but I'm coming around to it.

One piece of functionality we have is a 'queue-ing' system. There is an image queue that users have to go through to 'vet' photos. In this instance of work I needed to update a collection of records. It didn't matter which ones, just enough to fill the queue.

view plain print about
1UPDATE tableName
2SET active = 0
3LIMIT 500;

So rather than using a where clause it seems that you can use a mySql LIMIT value, to just return a set number of records.

Simple but effective.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Back to top