Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add to union query

Status
Not open for further replies.

Netherby

Programmer
Nov 9, 2001
32
GB
Hi,

I have a union query that combines two sets of names together.

It works well and my SQL is as follows

SELECT tblName.LastName
FROM tblName UNION SELECT tblName1.LastName
FROM tblName1

I'd now like to add the name 'Smith' to my query result and have tried the following and several variations with no success.

SELECT tblName.LastName
FROM tblName UNION SELECT tblName1.LastName
FROM tblName1 UNION SELECT 'Smith'

Could someone please tell me the correct syntax.

Thanks.
 
Your last SELECT doesn't correspond to the
Code:
SELECT field FROM table
format required for a SELECT statement

Try
Code:
SELECT tblName.LastName FROM tblName 

UNION 

SELECT tblName1.LastName FROM tblName1 

UNION 

SELECT TOP 1 'Smith' From tblName
 
Quite right Duane.

I guess the old adage is true.

Memory is the second thing to go ... and I don't remember what the first thing is.
 
Thanks guys. It works perfectly without Top 1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top