sql select query - 连接中列的别名不起作用

时间:2015-12-31 08:52:21

标签: sql

我有一个工作正常的查询..

SELECT 
    WSDEFN.WORKSPACE_DISPLAY_NM,
    LAYDEFN.LAYOUT_DISPLAY_NM,
    WSLMAP.POSITION,
    LAYDEFN.LAYOUT,
    LAYDEFN.PROPORTION,
    LAYDEFN.LAYOUT_ID,
    WSDEFN.WORKSPACE_ID,
    LAYDEFN.BUNDLE_KEY 
FROM 
    WORKSPACE_DEFINITION WSDEFN,
    WORKSPACE_LAYOUT_MAP WSLMAP,
    LAYOUT_DEFINITION LAYDEFN
WHERE 
    WORKSPACE_ID = WSLMAP.WORKSPACE_ID
    AND WSLMAP.LAYOUT_ID = LAYDEFN.LAYOUT_ID 
    AND WSDEFN.OD_USER_NO = '-1' 
    AND WSDEFN.OD_GCIF = '-1'
ORDER BY 
    wsdefn.workspace_id, WSLMAP.POSITION

但我想将WSDEFN.WORKSPACE_ID取为WORKSPACE_ID

我试过这个

WSDEFN.WORKSPACE_ID AS WORKSPACE_ID,

但是我收到了错误

  

'列模糊定义'

你能给我一个解决方案吗?

1 个答案:

答案 0 :(得分:3)

似乎缺少where子句中的表别名。

你尝试过这个吗?

            SELECT 
                WSDEFN.WORKSPACE_DISPLAY_NM,
                LAYDEFN.LAYOUT_DISPLAY_NM,
                WSLMAP.POSITION,
                LAYDEFN.LAYOUT,
                LAYDEFN.PROPORTION,
                LAYDEFN.LAYOUT_ID,
                WSDEFN.WORKSPACE_ID AS WORKSPACE_ID,  
                LAYDEFN.BUNDLE_KEY 
            FROM 
                WORKSPACE_DEFINITION WSDEFN,
                WORKSPACE_LAYOUT_MAP WSLMAP,
                LAYOUT_DEFINITION LAYDEFN
           WHERE 
               WSDEFN.WORKSPACE_ID = WSLMAP.WORKSPACE_ID
           AND 
                WSLMAP.LAYOUT_ID      = LAYDEFN.LAYOUT_ID 
           AND 
                WSDEFN.OD_USER_NO='-1' AND WSDEFN.OD_GCIF='-1'
           ORDER BY 
                wsdefn.workspace_id,WSLMAP.POSITION