我想问一下ms访问中的选择案例。从我得到的是db2 任何人都可以帮助更改MS Access 2000的SQL
SELECT DISTINCT
CASE WHEN STORECODE='JPAT' THEN
CASE WHEN PARTNO LIKE 'A%' THEN
ITEMNAME||'(NIV-'||SECTIONNO||')'
WHEN PARTNO LIKE 'STSB%' THEN
ITEMNAME||' (NIV-'||SECTIONNO||')'
ELSE
ITEMNAME||'('||PARTNO||'-'||SECTIONNO||')'
END
ELSE
ITEMNAME||'('||PARTNO||'-'||SECTIONNO||')'
END
AS INPUTTEXT,
IDX||':'||PARTNO||':'||BATCHNO||':'||ITEMTYPECODE||':'||TOOLTYPECODE||':'||ITEMCATEGORYCODE||':'||MATERIALTYPECODE||':'||SECTIONNO AS INPUTVAL
from ITEM where idx > 0 and (storecode)='JPAT'
感谢
答案 0 :(得分:1)
在MS Access中,这看起来像:
SELECT DISTINCT
IIF(PARTNO LIKE 'A*', ITEMNAME & "(NIV-" & SECTIONNO & ")"
IIF(PARTNO LIKE "STSB*", ITEMNAME & " (NIV-" & SECTIONNO & ")"
ITEMNAME & "(" & PARTNO & "-" & SECTIONNO & ")"
)
) AS INPUTTEXT,
(IDX & ":" & PARTNO & ":" & BATCHNO & ":" & ITEMTYPECODE & ":" &
TOOLTYPECODE & ":"& ITEMCATEGORYCODE & ":" & MATERIALTYPECODE &
":" & SECTIONNO
) AS INPUTVAL
FROM ITEM
WHERE idx > 0 AND storecode = "JPAT";
注意:
storecode = 'JPAT'
中不需要比较SELECT
,因为它位于WHERE
。"
,而非'
。&
。LIKE
中的通配符为*
。CASE
。我发现IIF()
足以满足这种情况(双关语)。