jemz — 2013-08-28T21:48:52-04:00 — #1
Hi, can i ask some help,How can i do this in my sql query to have Case statement?
Example in my employee table i want to have case statement on my empno.
select * from employee
when empno = "000070" then firstname = "Jack"
when empno = "000050" then firstnmae = "Stellar"
when empno = "000030" then firstname = "Sheek"
else firstname = "jemz"
can you help me please i am confuse in my querry.
Thank you in advance.:)
r937 — 2013-08-29T03:52:34-04:00 — #2
how hard did you try to look up the actual syntax and learn from the examples?
CASE WHEN empno = '000070' THEN 'Jack'
WHEN empno = '000050' THEN 'Stellar'
WHEN empno = '000030' THEN 'Sheek'
END AS firstname
also, the CASE expression is not allowed to some after the FROM clause
jemz — 2013-08-29T11:06:30-04:00 — #3
Actually i haven't see good example for this kind of problem
r937 — 2013-08-29T13:24:41-04:00 — #4
here you go --> http://www.devshed.com/c/a/MySQL/Advanced-Query-Writing-concluded/2/