SQL Union filters duplicate record statements and obtains data that is not duplicated
$sql = "UNION all->union -------------------- --How do I get data that is not duplicated in the following sentences? SELECT DISTINCT top PERCENT KIRINLDS.DBO.TBL personnel adjustment. Department name as department name From KIRINLDS.DBO.TBL personnel INNER JOIN KIRINLDS.DBO.TBL orders on KIRINLDS.DBO.TBL personnel. Work Number = KirinLDS.dbo.tbl order. Salesman INNER JOIN KIRINLDS.DBO.TBL personnel adjusted on KIRINLDS.DBO.TBL. Name = KIRINLDS.DBO.TBL personnel adjustment. Personnel WHERE (Left (kirinLDS.dbo.tbl order. Fiscal month, 4) = ' 2009 ')
UNION
SELECT DISTINCT top PERCENT KIRINSZ.DBO.TBL personnel adjustment. Department name as department name From KIRINSZ.DBO.TBL personnel INNER JOIN KIRINSZ.DBO.TBL orders on KIRINSZ.DBO.TBL personnel. Work Number = KirinSZ.dbo.tbl order. Salesman INNER JOIN KIRINSZ.DBO.TBL personnel adjusted on KIRINSZ.DBO.TBL. Name = KIRINSZ.DBO.TBL personnel adjustment. Personnel WHERE (Left (kirinSZ.dbo.tbl order. Fiscal month, 4) = ' 2009 ')
UNION
SELECT DISTINCT Top PERCENT KIRINLDSBJ.DBO.TBL personnel adjustments. Department name as department name from kirinLDSbj.dbo.tbl people INNER JOIN KIRINLDSBJ.DBO.TBL orders on KIRINLDSBJ.DBO.TBL personnel. Work Number = KirinLDSbj.dbo.tbl order. Clerk INNER JOIN KIRINLDSBJ.DBO.TBL personnel adjust on kirinLDSbj.dbo.tbl. Name = KIRINLDSBJ.DBO.TBL personnel adjustment. Person WHERE (left) KIRINLDSBJ.DBO.TBL orders. Fiscal month, 4 = ' 2009 ') ; We usually change Union all to Union. Look, the union query shows a record of not repeating oh.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.