Sunday, February 14, 2010

Tech: MYSQL

useful site for mysql setup
You can download mysql (use MSI one, it is easy to work with) from here: http://dev.mysql.com/downloads/mirror.php?id=382190#mirrors

You need to set the path environment variable by (http://techtracer.com/2008/06/09/3-easy-steps-to-install-mysql-on-windows-xp/):
My Computer > Properties > Advanced >Environment Variables > System variables > Path > Edit
and add the mysql installation path (e.g. C:\Program Files\MySQL\MySQL Server 5.1\bin)

MYSQL update with subquery on the same table doesn't work
This is very common in oracle and other sql based databases, but with MYSQL database currently, you cannot update a table and select from the same table in a subquery. The following query doesn't work: update t1 set col1='NO' where id=(select max(id) from t1)
Instead you can use the following hack:
update t1 set col1 = 'NO' order by id desc limit 1

No comments:

Post a Comment