当我尝试使用子查询创建视图时,mysql 出现问题
这是我想要制作视图的 SQL 脚本。
select
LOG_ID
,REF_ID
,TRX_ID
,TIME_EXEC
,STATUS
,RESULT_CODE
,ACCOUNT_NO
,AMOUNT
,REF_NO
,TASK_TYPE
,NAME_E
,NAME_I
from (
select
LT.LOG_ID
,LT.REF_ID
,LT.TRX_ID
,LT.TIME_EXEC
,LT.STATUS
,LT.RESULT_CODE
,TK.ACCOUNT_NO
,TK.AMOUNT
,TK.REF_NO
,TK.TASK_TYPE
,TT.NAME_E
,TT.NAME_I
from
IB_LOG_TRANSACTIONS LT, IB_TASKS TK, IB_TASK_TYPES TT
where
LT.TRX_ID is null
and LT.REF_ID = TK.REF_ID
and TK.TASK_TYPE = TT.TASK_TYPE
union (
select
LT.LOG_ID
,LT.REF_ID
,LT.TRX_ID
,LT.TIME_EXEC
,LT.STATUS
,LT.RESULT_CODE
,T.ACCOUNT_NO
,T.AMOUNT
,TK.REF_NO
,TK.TASK_TYPE
,TT.NAME_E
,TT.NAME_I
from
IB_LOG_TRANSACTIONS LT, IB_TRANSFERS T, IB_TASKS TK, IB_TASK_TYPES TT
where
LT.TRX_ID = T.TRX_ID
and LT.REF_ID = T.REF_ID
and LT.REF_ID = TK.REF_ID
and TK.TASK_TYPE = TT.TASK_TYPE
) union (
select
LT.LOG_ID
,LT.REF_ID
,LT.TRX_ID
,LT.TIME_EXEC
,LT.STATUS
,LT.RESULT_CODE
,TD.ACCOUNT_NO
,TD.AMOUNT
,TK.REF_NO
,TK.TASK_TYPE
,TT.NAME_E
,TT.NAME_I
from
IB_LOG_TRANSACTIONS LT, IB_TRANSFERS_DOM TD, IB_TASKS TK, IB_TASK_TYPES TT
where
LT.TRX_ID = TD.TRX_ID
and LT.REF_ID = TD.REF_ID
and LT.REF_ID = TK.REF_ID
and TK.TASK_TYPE = TT.TASK_TYPE
) union (
select
LT.LOG_ID
,LT.REF_ID
,LT.TRX_ID
,LT.TIME_EXEC
,LT.STATUS
,LT.RESULT_CODE
,TF.ACCOUNT_NO
,TF.AMOUNT
,TK.REF_NO
,TK.TASK_TYPE
,TT.NAME_E
,TT.NAME_I
from
IB_LOG_TRANSACTIONS LT, IB_TRANSFERS_FGN TF, IB_TASKS TK, IB_TASK_TYPES TT
where
LT.TRX_ID = TF.TRX_ID
and LT.REF_ID = TF.REF_ID
and LT.REF_ID = TK.REF_ID
and TK.TASK_TYPE = TT.TASK_TYPE
) union (
select
LT.LOG_ID
,LT.REF_ID
,LT.TRX_ID
,LT.TIME_EXEC
,LT.STATUS
,LT.RESULT_CODE
,P.ACCOUNT_NO
,P.AMOUNT
,TK.REF_NO
,TK.TASK_TYPE
,TT.NAME_E
,TT.NAME_I
from
IB_LOG_TRANSACTIONS LT, IB_PAYMENTS P, IB_TASKS TK, IB_TASK_TYPES TT
where
LT.TRX_ID = P.TRX_ID
and LT.REF_ID = P.REF_ID
and LT.REF_ID = TK.REF_ID
and TK.TASK_TYPE = TT.TASK_TYPE
))
我需要一个很大的帮助,这是我的 MYSQL 脚本,我对 MySQL 不是很熟悉。谢谢你帮助我:)