Union Query Error When Doing Multiple SELECTS

R

Ronster

I keep getting that SYNTAX ERROR IN FROM CLAUSE on the following code
(this is my first UNION query):

SELECT [SSN], [Last], [PeriodDate], [VendCode], [Type], [Amount]
FROM Deductions_1
UNION ALL
SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code], [VendorType],
[VendorAmount]
FROM DeductNormal
SELECT [SSN], [Last], [PeriodDate], [VendCode2], [Type2], [Amount2]
FROM Deductions_1
UNION ALL
SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code], [VendorType],
[VendorAmount]
FROM DeductNormal;

Both run OK separately.

Any ideas on this one?
 
M

Marshall Barton

Ronster said:
I keep getting that SYNTAX ERROR IN FROM CLAUSE on the following code
(this is my first UNION query):

SELECT [SSN], [Last], [PeriodDate], [VendCode], [Type], [Amount]
FROM Deductions_1
UNION ALL
SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code], [VendorType],
[VendorAmount]
FROM DeductNormal
SELECT [SSN], [Last], [PeriodDate], [VendCode2], [Type2], [Amount2]
FROM Deductions_1
UNION ALL
SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code], [VendorType],
[VendorAmount]
FROM DeductNormal;


There is a missing UNION ALL in there.
 
R

Ronster

Marshall said:
Ronster said:
I keep getting that SYNTAX ERROR IN FROM CLAUSE on the following code
(this is my first UNION query):

SELECT [SSN], [Last], [PeriodDate], [VendCode], [Type], [Amount]
FROM Deductions_1
UNION ALL
SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code], [VendorType],
[VendorAmount]
FROM DeductNormal
SELECT [SSN], [Last], [PeriodDate], [VendCode2], [Type2], [Amount2]
FROM Deductions_1
UNION ALL
SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code], [VendorType],
[VendorAmount]
FROM DeductNormal;


There is a missing UNION ALL in there.

BINGO! Thank you. That did it. Posting corrected code.

SELECT [SSN], [Last], [PeriodDate], [VendCode], [Type], [Amount]
FROM Deductions_1
UNION ALL SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code],
[VendorType], [VendorAmount]
FROM DeductNormal
UNION ALL SELECT [SSN], [Last], [PeriodDate], [VendCode2], [Type2],
[Amount2]
FROM Deductions_1
UNION ALL SELECT [SSN], [Last], [PayPeriodDate], [Vendor_Code],
[VendorType], [VendorAmount]
FROM DeductNormal;
 
Top