dbTalk Databases Forums  

two fields in table into one field in query

comp.database.ms-access comp.database.ms-access


Discuss two fields in table into one field in query in the comp.database.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
cdasteve
 
Posts: n/a

Default two fields in table into one field in query - 01-15-2004 , 06:03 PM






I was handed a database with the following fields: client name, client
birthday, spouse name, and spouse birthday. I was asked to get a
report listing all birthdays chronologically.

As a quick fix, I made 2 append queries that run in succession when
the report is called. The first query writes client name and birthday
to a new table called tbl_bday with 2 fields "name" and "birthday",
then the second query writes the spouse name and birthday to the same
table/fields.

Is there a better/more elegant way to get this report without
resorting to append query and a new table? Thanks.

Reply With Quote
  #2  
Old   
Felovala
 
Posts: n/a

Default Re: two fields in table into one field in query - 01-15-2004 , 09:24 PM






Try:

SELECT [client name] AS [name], [client birthday] AS [birthday] FROM
[tblClients] WHERE [client birthday] is not null
UNION
SELECT [spouse name] AS [name], [spouse birthday] AS [birthday] FROM
[tblClients] WHERE [spouse birthday] is not null
ORDER BY [birthday];

The is null is optional, but it removes anyone that does not have a birthday

Good Luck

"cdasteve" <steveocda (AT) hotmail (DOT) com> wrote

Quote:
I was handed a database with the following fields: client name, client
birthday, spouse name, and spouse birthday. I was asked to get a
report listing all birthdays chronologically.

As a quick fix, I made 2 append queries that run in succession when
the report is called. The first query writes client name and birthday
to a new table called tbl_bday with 2 fields "name" and "birthday",
then the second query writes the spouse name and birthday to the same
table/fields.

Is there a better/more elegant way to get this report without
resorting to append query and a new table? Thanks.



Reply With Quote
  #3  
Old   
cdasteve
 
Posts: n/a

Default Re: two fields in table into one field in query - 01-16-2004 , 06:42 PM



It works. Thanks very much for the explanation on the union query.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.