我在MSSQL中有这个查询.. 如何将其转换为MYSQL查询..
CREATE VIEW DATA_VIEW AS SELECT A.*,B.FIELD_VALUE D1_VALUE,C.FIELD_VALUE D2_VALUE,D.FIELD_VALUE
C_VALUE FROM DB_DATA A
FULL OUTER JOIN T_CASE_D1 B ON A.FIELD_ID =B.FIELD_ID AND B.CASE_ID=47758
FULL OUTER JOIN T_CASE_D2 C ON A.FIELD_ID =C.FIELD_ID AND C.CASE_ID=47758
FULL OUTER JOIN T_CASE_QC D ON A.FIELD_ID =D.FIELD_ID AND D.CASE_ID=47758
WHERE A.FORM_ID=5 AND IS_ACTIVE='Y'
提前致谢
答案 0 :(得分:2)
您的where
条款正在将FULL OUTER JOIN
转换为LEFT JOIN
,所以您不妨使用它:
CREATE VIEW DATA_VIEW AS
SELECT A.*, B.FIELD_VALUE D1_VALUE, C.FIELD_VALUE D2_VALUE, D.FIELD_VALUE AS C_VALUE
FROM DB_DATA A LEFT JOIN
T_CASE_D1 B
ON A.FIELD_ID = B.FIELD_ID AND B.CASE_ID = 47758 LEFT OUTER JOIN
T_CASE_D2 C
ON A.FIELD_ID = C.FIELD_ID AND C.CASE_ID = 47758 LEFT OUTER JOIN
T_CASE_QC D
ON A.FIELD_ID =D.FIELD_ID AND D.CASE_ID = 47758
WHERE A.FORM_ID=5 AND IS_ACTIVE = 'Y';
在具有适当维护的外键关系的数据库中很少需要 FULL OUTER JOIN
。