Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default value for switch in access 2007

I am using switch statement in access 2007, i want to know how I can specify default value

select 
  switch
  (
  MyCol = 1, 'Value is One',
  MyCol = 2, 'Value is Two'
  ) from MyTable

Thanks

like image 736
Mandeep Singh Avatar asked Apr 30 '13 06:04

Mandeep Singh


2 Answers

SELECT
Switch(MyTable.[MyCol]='1','Terrestrial',
MyTable.[MyCol]='2','Value is two',MyTable.[MyCol]='3','Value is three',
True,'Error') AS ColumnName
FROM MyTable;
like image 142
jainvikram444 Avatar answered Oct 17 '22 13:10

jainvikram444


select 
  switch
  (
  MyCol = 1, 'Value is One',
  MyCol = 2, 'Value is Two'
  True,"Default"
  ) from MyT

Refer:

http://www.utteraccess.com/forum/Switch-statement-default-t453140.html

like image 15
Freelancer Avatar answered Oct 17 '22 11:10

Freelancer