|
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.
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.
|
Trade marking Emoticons? ;-) |
|
Adobe brings AIR to Linux |
|
MySQL does not support conditional if/else scripts unless its compiled |
I've recently changed companies, and as a consequence changed some toolsets. One of these is a switch from MS SQL to MY SQL. Its an interesting learning curve, and I'm trying to stay open minded, but I really did quite like MS SQL....
I have a series of scripts that I have built over the years, they perform standard functions like creating tables, alters creating stored procs etc... (will post soon!). They are all self checking, and output nice processing messages to tell the user whats going on.
So I embarked on a mission to convert these to MY SQL. My first stumbling block was not referencing the master table form MS SQL, as it doesn't exist in MY SQL, but handily there is something similar.
2FROM information_schema.tables
3WHERE table_schema = DBName
4AND table_name = tableName
The problem then comes with evaluating this result into an IF statement. It turns out that MY SQL cannot process IF-ELSE conditionals unless it is within a compiled script, like a stored proceedure.
Bit of a show stopper there! So now I am trying to find another way to check for the existence of database objects.