Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 3rd, 2006, 06:07 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to join all records from both tables?

I've linked two tables, but found that there were only 3 types of links, However, what I what to do is to include all the records from both tables, how can I do that?

Reply With Quote
  #2 (permalink)  
Old January 3rd, 2006, 09:30 PM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It sounds like you want to combine records from two tables (so if one contains records APPLE, ORANGE, PLUM, and the other contains records LETTUCE and ONION you want a single recordset containing APPLE, LETTUCE, ONION, ORANGE, and PLUM.
What you need is a "union query".

1) Make a query which selects the field(s) you want from the first table.
2) With the query open in design view, select SQL from the view menu.
3) If your table is called tblFruits the query's SQL will look something like this:

SELECT tblFruits.*
FROM tblFruits
ORDER BY tblFruits.Name;

4) To include another table called tblVegetables, change the code as follows:

SELECT tblFruits.*
FROM tblFruits

UNION SELECT tblVegetables.*
FROM tblVegetables
ORDER BY tblFruits.Name;

5) There's other customisation you can do - see the help file.
Reply With Quote
  #3 (permalink)  
Old January 4th, 2006, 12:27 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

very helpful. thanks a lot :D

Reply With Quote
  #4 (permalink)  
Old January 4th, 2006, 12:39 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can we make a new query out of this "union query"? if so, how to do it?
many many thanks!

Reply With Quote
  #5 (permalink)  
Old January 4th, 2006, 01:36 PM
Friend of Wrox
 
Join Date: Dec 2005
Location: , , .
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If you're using VBE it works the same as any other query, if you're using the Query Designer simply change the view to SQL View and enter the code as shown above.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Join tables help tdaustin Classic ASP Databases 2 January 11th, 2006 04:57 PM
how to inner join tables gilgalbiblewheel Classic ASP Databases 4 January 31st, 2005 08:04 PM
Join Tables tdaustin Classic ASP Basics 1 May 25th, 2004 07:31 AM
Inner Join multiple tables qwprince Classic ASP Databases 5 July 23rd, 2003 02:33 PM



All times are GMT -4. The time now is 01:21 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.