You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

请求将DB2 CASE语句转换为MS Access 2000兼容的SQL查询语句

Hey there! Let's tackle converting your DB2 SQL to work with MS Access 2000. The main adjustments we need to make are replacing DB2's CASE WHEN logic with Access's IIF function and swapping the string concatenation operator || for Access's & (since || acts as a logical OR in Access SQL, not a string joiner).

Here's the converted query that should work seamlessly in Access 2000:

SELECT DISTINCT
    IIF(STORECODE='JPAT',
        IIF(PARTNO LIKE 'A%',
            ITEMNAME & '(NIV-' & SECTIONNO & ')',
            IIF(PARTNO LIKE 'STSB%',
                ITEMNAME & ' (NIV-' & SECTIONNO & ')',
                ITEMNAME & '(' & PARTNO & '-' & SECTIONNO & ')'
            )
        ),
        ITEMNAME & '(' & PARTNO & '-' & SECTIONNO & ')'
    ) AS INPUTTEXT,
    IDX & ':' & PARTNO & ':' & BATCHNO & ':' & ITEMTYPECODE & ':' & TOOLTYPECODE & ':' & ITEMCATEGORYCODE & ':' & MATERIALTYPECODE & ':' & SECTIONNO AS INPUTVAL
FROM ITEM
WHERE idx > 0 AND STORECODE='JPAT'

Key Changes Breakdown:

  • CASE WHEN → Nested IIF: Access 2000 doesn't support standard SQL CASE statements, so we use IIF(condition, result_if_true, result_if_false) instead. Each layer of your original CASE logic translates to a nested IIF call.
  • String Concatenation Fix: Replaced every || with & – this is the correct operator for joining strings in Access SQL.
  • Cleaned Up WHERE Clause: Removed unnecessary parentheses around storecode to make the query more readable (the original syntax would still work, but this is cleaner).

If you hit any snags testing this, feel free to follow up!

内容的提问来源于stack exchange,提问作者Irwan Ahmad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:33:41