4
我想用一個子查詢MySQL的 - 在FROM子句
CREATE OR REPLACE VIEW `V_TASK_TRANSFER` (`REF_ID`, `DATE_CREATE`, `DATE_TRX`,
`ACCOUNT_NO`, `TO_ACCOUNT_NO`, `TO_NAME`, `CURRENCY_CODE`, `AMOUNT`,
`TASK_TYPE`, `NAME_E`, `NAME_I`, `REF_NO`, `EXECUTION_TYPE`,
`REVIEW_COUNT`, `REVIEW_NEED`, `APPROVE_COUNT`, `APPROVE_NEED`,
`TRX_COUNT_SUCCESS`, `TRX_COUNT_FAIL`, `TRX_COUNT_ALL`,
`STATUS_TF`, `USER_ID`
) AS
SELECT REF_ID,
DATE_CREATE,
DATE_TRX,
ACCOUNT_NO,
TO_ACCOUNT_NO,
TO_NAME,
CURRENCY_CODE,
AMOUNT,
TASK_TYPE,
NAME_E,
NAME_I,
REF_NO,
EXECUTION_TYPE,
REVIEW_COUNT,
REVIEW_NEED,
APPROVE_COUNT,
APPROVE_NEED,
TRX_COUNT_SUCCESS,
TRX_COUNT_FAIL,
TRX_COUNT_ALL,
STATUS_TF,
USER_ID
FROM
(SELECT T.REF_ID,
T.DATE_CREATE,
T.DATE_TRX,
TTF.ACCOUNT_NO,
TTF.TO_ACCOUNT_NO,
TTF.TO_NAME,
TTF.CURRENCY_CODE,
TTF.AMOUNT,
T.TASK_TYPE,
TT.NAME_E,
TT.NAME_I,
T.REF_NO,
T.EXECUTION_TYPE,
T.REVIEW_COUNT,
T.REVIEW_NEED,
T.APPROVE_COUNT,
T.APPROVE_NEED,
T.TRX_COUNT_SUCCESS,
T.TRX_COUNT_FAIL,
T.TRX_COUNT_ALL,
T.STATUS_TF,
T.USER_ID
FROM IB_TASKS T
JOIN IB_TASK_TRANSFERS TTF ON T.REF_ID = TTF.REF_ID
JOIN IB_TASK_TYPES TT ON TT.TASK_TYPE = T.TASK_TYPE
UNION
SELECT T.REF_ID,
T.DATE_CREATE,
T.DATE_TRX,
TTF.ACCOUNT_NO,
TTF.TO_ACCOUNT_NO,
TTF.TO_NAME,
TTF.CURRENCY_CODE,
TTF.AMOUNT,
T.TASK_TYPE,
TT.NAME_E,
TT.NAME_I,
T.REF_NO,
T.EXECUTION_TYPE,
T.REVIEW_COUNT,
T.REVIEW_NEED,
T.APPROVE_COUNT,
T.APPROVE_NEED,
T.TRX_COUNT_SUCCESS,
T.TRX_COUNT_FAIL,
T.TRX_COUNT_ALL,
T.STATUS_TF,
T.USER_ID
FROM IB_TASKS T
JOIN IB_TASK_TRANSFERS_DOM TTF ON T.REF_ID = TTF.REF_ID
JOIN IB_TASK_TYPES TT ON TT.TASK_TYPE = T.TASK_TYPE
UNION
SELECT T.REF_ID,
T.DATE_CREATE,
T.DATE_TRX,
TTF.ACCOUNT_NO,
TTF.TO_ACCOUNT_NO,
TTF.TO_NAME,
TTF.CURRENCY_CODE,
TTF.AMOUNT,
T.TASK_TYPE,
TT.NAME_E,
TT.NAME_I,
T.REF_NO,
T.EXECUTION_TYPE,
T.REVIEW_COUNT,
T.REVIEW_NEED,
T.APPROVE_COUNT,
T.APPROVE_NEED,
T.TRX_COUNT_SUCCESS,
T.TRX_COUNT_FAIL,
T.TRX_COUNT_ALL,
T.STATUS_TF,
T.USER_ID
FROM IB_TASKS T
JOIN IB_TASK_TRANSFERS_FGN TTF ON T.REF_ID = TTF.REF_ID
JOIN IB_TASK_TYPES TT ON TT.TASK_TYPE = T.TASK_TYPE
);
創建視圖在MySQL中創建一個使用子查詢的看法,但它給了我
錯誤#1349 - 視圖的SELECT語句包含在子查詢FROM子句
我該如何解決這個限制?
感謝隊友:d這是真正的幫助..即時通訊在MySQL新手 –