UNION函数
连接函数
SELECT
A1. ID,
A1.TEST_OBJECT_ID,
BIZ_ITEM_ID,
BIZ_ITEM_TYPE,
A2.ASSAY_ITEM_NAME BIZ_ITEM_NAME
FROM
DIC_ASSAY_BUSINESS_ITEM A1,
DIC_ASSAY_ITEM A2
WHERE
A1.BIZ_ITEM_TYPE = 2
AND A1.BIZ_ITEM_ID = A2. ID
AND A1.TEST_OBJECT_ID = A2.TEST_OBJECT_ID
UNION
SELECT
B1. ID,
B1.TEST_OBJECT_ID,
BIZ_ITEM_ID,
BIZ_ITEM_TYPE,
B2.BIZ_TASK_NAME BIZ_ITEM_NAME
FROM
DIC_ASSAY_BUSINESS_ITEM B1,
DIC_BUSINESS_TASK B2
WHERE
B1.BIZ_ITEM_TYPE = 3
AND B1.BIZ_ITEM_ID = B2. ID
AND B1.TEST_OBJECT_ID = B2.TEST_OBJECT_ID
注意
Union两边的列数,必须一致