这个错误在哪里? (访问查询)

时间:2017-06-08 14:21:17

标签: sql ms-access

SELECT [02d1_NTS_Report_Structure].Nation, [02d1_NTS_Report_Structure].Region, 
    [02d1_NTS_Report_Structure].Territory, [02d1_NTS_Report_Structure].Zone,
    iif ([02d1_NTS_Report_Structure].Zone="-", 
        iff ([02d1_NTS_Report_Structure].Territory="-",
            iff ([02d1_NTS_Report_Structure].Region="-", 
                [02d1_NTS_Report_Structure].Nation, 
                [02d1_NTS_Report_Structure].Region),
        [02d1_NTS_Report_Structure].Territory), 
    [02d1_NTS_Report_Structure].Zone)
FROM 02d1_NTS_Report_Structure;

2 个答案:

答案 0 :(得分:2)

看起来你正在使用" IFF"而不是" IIF"在几个地方。

试试这个:

SELECT [02d1_NTS_Report_Structure].Nation, [02d1_NTS_Report_Structure].Region, 
    [02d1_NTS_Report_Structure].Territory, [02d1_NTS_Report_Structure].Zone,
    iif ([02d1_NTS_Report_Structure].Zone="-", 
        iif ([02d1_NTS_Report_Structure].Territory="-",
            iif ([02d1_NTS_Report_Structure].Region="-", 
                [02d1_NTS_Report_Structure].Nation, 
                [02d1_NTS_Report_Structure].Region),
        [02d1_NTS_Report_Structure].Territory), 
    [02d1_NTS_Report_Structure].Zone)
FROM 02d1_NTS_Report_Structure;

答案 1 :(得分:0)

我唯一能看到的是你可能应该在表名周围加上括号:

SELECT [02d1_NTS_Report_Structure].Nation, 
[02d1_NTS_Report_Structure].Region, 
[02d1_NTS_Report_Structure].Territory, 
[02d1_NTS_Report_Structure].Zone, 
IIF([02d1_NTS_Report_Structure].Zone="-", 
    IIF([02d1_NTS_Report_Structure].Territory="-",
       IIF([02d1_NTS_Report_Structure].Region="-", 
           [02d1_NTS_Report_Structure].Nation,
           [02d1_NTS_Report_Structure].Region),
        [02d1_NTS_Report_Structure].Territory), 
     [02d1_NTS_Report_Structure].Zone) 
    FROM [02d1_NTS_Report_Structure];