help me out for this problem...

help me out for this problem...

am 05.02.2010 13:03:44 von MuraliKrishna

------=_NextPart_000_0004_01CAA689.604DC400
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit



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>


------=_NextPart_000_0004_01CAA689.604DC400--

RE: help me out for this problem...

am 05.02.2010 13:16:29 von misiaQ

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_krishna@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=gcdmg-mysql-2@m.gmane.org

Re: help me out for this problem...

am 05.02.2010 14:52:22 von Ramesh

--001636b2b280f011a0047edac3d7
Content-Type: text/plain; charset=ISO-8859-1

See this link.

Might me help for you

http://answers.yahoo.com/question/index?qid=20070309043307AA TLe9k

On 5 February 2010 17:46, misiaQ wrote:

> 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_krishna@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=ramesh4f@gmail.com
>
>


--
Ramesh

--001636b2b280f011a0047edac3d7--