mysql - CASE statement not working well -
hey guys new mysql actually..i have wrote code like
create table customers( id int not null, name varchar (20) not null, age int not null, address char (25) , salary decimal (18, 2), primary key (id) ); insert customers (id,name,age,address,salary) values (1,'aff',2,3,5);
my case statement like
select case when id > 0 set name = 'sdfsdf'; else set name = 'asd' end case; customers
when run on sql fiddle gives me error
you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'set name = 'sdfsdf'; else set name = 'asd' end case' @ line 1: select case when id > 0 set name = 'sdfsdf'; else set name = 'asd' end case
can me ..any appreciatd
the correct statement
select case when id > 0 'sdfsdf' else 'asd' end name customers ;
Comments
Post a Comment