We usually use unionall to change to union. The union query shows records that are not repeated.
// We usually use union all to change to union. The union query shows records that are not repeated.
SQL UNION filters duplicate record statements and obtains non-duplicated data
$ SQL = "UNION ALL-> UNION
--------------------
-- How to obtain non-repeated data in the following sentence?
Select distinct top 100 PERCENT kirinLDS. dbo. tbl personnel adjustment. Department name AS department name
FROM kirinLDS. dbo. tbl personnel INNER JOIN
KirinLDS. dbo. tbl order ON kirinLDS. dbo. tbl personnel. employee ID = kirinLDS. dbo. tbl order. Clerk INNER JOIN
KirinLDS. dbo. tbl personnel adjustment ON kirinLDS. dbo. tbl personnel. Name = kirinLDS. dbo. tbl personnel adjustment. Personnel
WHERE (LEFT (kirinLDS. dbo. tbl order. monthly accounting, 4) = '123 ')
UNION
Select distinct top 100 PERCENT kirinSZ. dbo. tbl personnel adjustment. Department name AS department name
FROM kirinSZ. dbo. tbl personnel INNER JOIN
KirinSZ. dbo. tbl order ON kirinSZ. dbo. tbl personnel. employee ID = kirinSZ. dbo. tbl order. Salesman INNER JOIN
KirinSZ. dbo. tbl personnel adjustment ON kirinSZ. dbo. tbl personnel. Name = kirinSZ. dbo. tbl personnel adjustment. Personnel Adjustment
WHERE (LEFT (kirinSZ. dbo. tbl order. monthly accounting, 4) = '123 ')
UNION
Select distinct top 100 PERCENT kirinLDSbj. dbo. tbl personnel adjustment. Department name AS department name
FROM kirinLDSbj. dbo. tbl personnel INNER JOIN
KirinLDSbj. dbo. tbl order ON kirinLDSbj. dbo. tbl personnel. employee ID = kirinLDSbj. dbo. tbl order. Clerk INNER JOIN
KirinLDSbj. dbo. tbl personnel adjustment ON kirinLDSbj. dbo. tbl personnel. Name = kirinLDSbj. dbo. tbl personnel adjustment. Personnel Adjustment
WHERE (LEFT (kirinLDSbj. dbo. tbl order. monthly accounting, 4) = '123 ')
";
// We usually use union all to change to union. The union query shows records that are not repeated.