在 access 2007 中切换的默认值
Posted
技术标签:
【中文标题】在 access 2007 中切换的默认值【英文标题】:default value for switch in access 2007 【发布时间】:2013-04-30 06:42:05 【问题描述】:我在 access 2007 中使用 switch 语句,我想知道如何指定默认值
select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
) from MyTable
谢谢
【问题讨论】:
【参考方案1】:SELECT
Switch(MyTable.[MyCol]='1','Terrestrial',
MyTable.[MyCol]='2','Value is two',MyTable.[MyCol]='3','Value is three',
True,'Error') AS ColumnName
FROM MyTable;
【讨论】:
我要求 ms-access 查询【参考方案2】:select
switch
(
MyCol = 1, 'Value is One',
MyCol = 2, 'Value is Two'
True,"Default"
) from MyT
参考:
http://www.utteraccess.com/forum/Switch-statement-default-t453140.html
【讨论】:
【参考方案3】:Swich 命令的语法是:
Switch(TestCase1, Result1, TestCase2, Result2, As many more TestCases and Results as you need..., DefaultResult)
请注意,DefaultResult 是一个可选参数,如果实际数据与任何测试用例都不匹配,则会提供响应。
【讨论】:
以上是关于在 access 2007 中切换的默认值的主要内容,如果未能解决你的问题,请参考以下文章