日期:2014-05-17 浏览次数:20559 次
SELECT *
FROM (
SELECT LINK.PARENT_SERIAL_NUMBER_ID AS ME_SERIAL_NUMBER_ID,
PARENTSNSERIAL.PRODUCT_ID,
PARENTSNSERIAL.LOT_ID,
COMPONENT.NAME AS ME_NAME
FROM MESDB.DBO.QS_SERIAL_NUMBERS SNSERIAL
INNER JOIN MESDB.DBO.QS_SN_LINKS LINK ON SNSERIAL.SERIAL_NUMBER_ID=LINK.CHILD_SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_SERIAL_NUMBERS PARENTSNSERIAL ON LINK.PARENT_SERIAL_NUMBER_ID=PARENTSNSERIAL.SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_COMPONENTS COMPONENT ON PARENTSNSERIAL.PRODUCT_ID=COMPONENT.PRODUCT_ID
WHERE SNSERIAL.SERIAL_NUMBER='847603030100834665'
) MECOMPONET LEFT OUTER JOIN (
SELECT LINK.PARENT_SERIAL_NUMBER_ID, COMPONENTS.NAME , SN.SERIAL_NUMBER
FROM MESDB.DBO.QS_SN_LINKS LINK
INNER JOIN MESDB.DBO.QS_SERIAL_NUMBERS SN ON LINK.CHILD_SERIAL_NUMBER_ID=SN.SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_COMPONENTS COMPONENTS ON LINK.CHILD_COMPONENT_ID=COMPONENTS.COMPONENT_ID
WHERE PARENT_SERIAL_NUMBER_ID=(
SELECT LINK.PARENT_SERIAL_NUMBER_ID
FROM MESDB.DBO.QS_SERIAL_NUMBERS SN
INNER JOIN MESDB.DBO.QS_SN_LINKS LINK ON SN.SERIAL_NUMBER_ID=LINK.CHILD_SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_SERIAL_NUMBERS SNPARENT ON LINK.PARENT_SERIAL_NUMBER_ID=SNPARENT.SERIAL_NUMBER_ID
WHERE SN.SERIAL_NUMBER='847603030100834665'
)
) MEMPURSUE ON MECONPONET.ME_SERIAL_NUMBER_ID=MEMPURSUE.PARENT_SERIAL_NUMBER_ID AND MECONPONET.ME_NAME=MEMPURSUE.NAME
SELECT *
FROM (
SELECT LINK.PARENT_SERIAL_NUMBER_ID AS ME_SERIAL_NUMBER_ID,
PARENTSNSERIAL.PRODUCT_ID,
PARENTSNSERIAL.LOT_ID,
COMPONENT.NAME AS ME_NAME
FROM MESDB.DBO.QS_SERIAL_NUMBERS SNSERIAL
INNER JOIN MESDB.DBO.QS_SN_LINKS LINK ON SNSERIAL.SERIAL_NUMBER_ID=LINK.CHILD_SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_SERIAL_NUMBERS PARENTSNSERIAL ON LINK.PARENT_SERIAL_NUMBER_ID=PARENTSNSERIAL.SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_COMPONENTS COMPONENT ON PARENTSNSERIAL.PRODUCT_ID=COMPONENT.PRODUCT_ID
WHERE SNSERIAL.SERIAL_NUMBER='847603030100834665'
) MECOMPONET LEFT OUTER JOIN (
SELECT LINK.PARENT_SERIAL_NUMBER_ID, COMPONENTS.NAME , SN.SERIAL_NUMBER
FROM MESDB.DBO.QS_SN_LINKS LINK
INNER JOIN MESDB.DBO.QS_SERIAL_NUMBERS SN ON LINK.CHILD_SERIAL_NUMBER_ID=SN.SERIAL_NUMBER_ID
INNER JOIN MESDB.DBO.QS_COMPONENTS COMPONENTS ON LINK.CHILD_COMPONENT_ID=COMPONENTS.COMPONENT_ID
WHERE PARENT_SERIAL_NUMBER_ID=(
SELECT aa.PARENT_SERIAL_NUMBER_ID