Union Query Error When Doing Multiple SELECTS

  • Thread starter Thread starter Ronster
  • Start date Start date
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?
 
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.
 
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top