SQL Syntax Bug

G

Guest

I'm writing a query and I'm getting a syntax error but I'm not seeing it
when I look at it and the error message isn't telling me where it is at. For
starters, does anyone see my mistake, and better yet does anyone know of a
bug hunting software that will give better details as to where the bug is?

My query:

SELECT First([First Name]) AS [Family First Name],
First([Last Name]) AS [Family Last Name],
[Matchfield],
First([Weld Co ID]) AS [Family Address ID]

FROM [PrimaryVoterTier]

GROUP BY [Matchfield]

HAVING (((Count(*))=1));

UNION SELECT
First([First Name]) & " and " Last([First Name]) AS [Family First Name],
First([Last Name]) AS [Family Last Name],
[Matchfield],
First([Weld Co ID]) AS [Family Address ID]

FROM [PrimaryVoterTier]

GROUP BY [Matchfield]

HAVING (((Count(*)=2));

UNION SELECT
"The " & First([Last Name]) & " Family" AS [Family First Name],
" " AS [Family Last Name],
[Matchfield],
First([Weld Co ID]) AS [Family Address ID]

FROM [PrimaryVoterTier]

GROUP BY [Matchfield]

HAVING (((Count(*)>2));
 
J

Jeff Boyce

Do each of the separate queries within the union work correctly? Confirm
this first, then assemble those back together.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
G

Gary Walter

one thing:

the ";" are not allowed before the UNION's
--> delete them

"In need of assistance"wrote:
 

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

Top