访问表中的表达式

时间:2015-02-10 14:40:56

标签: ms-access switch-statement iif

我会收集我的IIF或在表格中切换表达式作为记录(超过40个):

tbl_filter:

过滤

Description LIKE '*SCREW*',"Screw"

Description LIKE '*SOCKET*',"SScrew"

如何在查询中的switch函数中的 tbl_filter 中使用此表达式集合?

类似这样:

SELECT Item, switch(Select * from tbl_Filter) AS Cathegory FROM tbl_Materials

提前感谢您的帮助

1 个答案:

答案 0 :(得分:0)

我认为你的意思如下。

tbl_Filter

Contains    Filter
Screw       Screw
Socket      Sscrew

tbl_Main

Description
Screws and sockets
Screw
Socket

查询SQL

SELECT tbl_Main.Description, tbl_Filter.Filter
FROM tbl_Main, tbl_Filter
WHERE tbl_Main.Description Like "*" & [Contains] & "*"

结果

Description         Filter
Screws and sockets  Screw
Screws and sockets  Sscrew
Screw               Screw
Socket              Sscrew