Question : Creating Query in MS Access 2003

I have a table called AVIATION DATA with the following fields:

AVIATION DATA.UNIQUE
AVIATION DATA.ID #1
AVIATION DATA.ID #1 COMMENTS
AVIATION DATA.ID #2
AVIATION DATA.ID #2 COMMENTS
AVIATION DATA.ID #3
AVIATION DATA.ID #3 COMMENTS

........continuing sequentially until ID #32 COMMENTS.

NOTE: Although UNIQUE contains only unique values the ID #1, ID #2 etc. fields could contain the same value but with different respective comments in the ID #1, ID #2 etc. COMMENTS fields. For example:

UNIQUE               ID #1         ID #1 COMMENTS          ID #2         ID #2 COMMENTS
B737_23456       N737BA    Boeing                            N737BA    Delta Air Lines
MD80_48999      N999GG    Douglas                         N999GG    Air Aruba      

I  have another table called LT_REG ENTRY with a single field:

LT_REG ENTRY.ID

I want to create a query that returns any exact matches between LT_REG ENTRY.ID and the ID #1, ID #2, ID #3 values and also returns the respective ID #1 COMMENTS, ID #2 COMMENTS etc.

I need the query to return the data in the following format assuming that LT_REG ENTRY.ID contained the value "N999GG", the query would return:

AVIATION DATA.UNIQUE         LT_REG ENTRY.ID       "COMMENTS"
MD80_48999                             N999GG                      Douglas
MD80_48999                             N999GG                      Air Aruba

Any help very much appreciated!

Cheers Mark.

Answer : Creating Query in MS Access 2003

LT_REG ENTRY has no relevance to this requirement.

What yolu have to do is create 32 queries which have to be put into a single Union All query.

Select [UNIQUE], [ID #1] as ID, [ID #1 COMMENTS] as Comments from [AVIATION DATA] where [ID #1] is not null
Union All
Select [UNIQUE], [ID #2] as ID, [ID #2 COMMENTS] as Comments from [AVIATION DATA] where [ID #2] is not null
Union All

Etc.....to..

Union All
Select [UNIQUE], [ID #32] as ID, [ID #32 COMMENTS] as Comments from [AVIATION DATA] where [ID #32] is not null
Order By Unique

This has to be done in the sql view of a new query.


Random Solutions  
 
programming4us programming4us