Instead of:
    -> else 2003

    -> where id between 1 and 6;
Try
    -> else 2003
    -> end
    -> where id between 1 and 6;

Or maybe even:
mysql> update table1
    -> set year=case when id IN (1, 2, 4) then 2000
    -> when id IN(2, 4, 6) then 2001
    -> else 2003
    -> end
    -> where id between 1 and 6;

Good luck!

Regards,
m

-----Original Message-----
From: MuraliKrishna [mailto:murali_kris...@arthaoptions.com] 
Sent: Friday, February 05, 2010 12:04 PM
To: mysql@lists.mysql.com
Subject: help me out for this problem...

 

Here I have to update year column with reference to the row id

 

 

mysql> update table1

    -> set year=case when id=1 then 2000

    -> when id=2 then 2001

    -> when id=3 then 2000

    -> when id=4 then 2001

    -> when id=5 then 2000

    -> when id=6 then 2001

    -> else 2003

    -> where id between 1 and 6;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
that

corresponds to your MySQL server version for the right syntax to use near
'where

 id between 1 and 6' at line 9

mysql>



----------------------------------------------------------------------
Urocze domki...
Zobacz >>> http://link.interia.pl/f25aa


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to