473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ms access query problem

Hi Everyone,

I am doing a small database in ms access. I have two tables: One has all
the information such as name, address, phone number, and etc. The second
table contains the keyID of the first table and some additional
information about the data in the first table( But not every record in
the first table will have additional information).
Something like this:
TABLE1:
KeyID Name Major
1 Jack PreMed
2 Tom Engineering
3 Susan Writing

TABLE2:
KeyID GPA Year
1 3.5 1999
1 3.4 2000
3 2.9 2000

When I use query:
Select Table1.Name, Table1.Major, Table2.GPA, Table2.Year
From Table1 inner join Table2 on Table1.KeyID = Table2.KeyID

I am only getting records that exists in both tables. How can I change
this query so that I will get all records from Table1 and all records
from Table2. Like this:

Name Major GPA Year
Jack PreMed 3.5 1999
Jack PreMed 3.4 2000
Tom Engineering
Susan Writing 2.9 2000

Thank you a lot for helping me out.

Jim

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
3 2607

"Jimmy Tran" <hu*******@yahoo.com> wrote in message
news:40*********************@news.frii.net...
Hi Everyone,

I am doing a small database in ms access. I have two tables: One has all
the information such as name, address, phone number, and etc. The second
table contains the keyID of the first table and some additional
information about the data in the first table( But not every record in
the first table will have additional information).
Something like this:
TABLE1:
KeyID Name Major
1 Jack PreMed
2 Tom Engineering
3 Susan Writing

TABLE2:
KeyID GPA Year
1 3.5 1999
1 3.4 2000
3 2.9 2000

When I use query:
Select Table1.Name, Table1.Major, Table2.GPA, Table2.Year
From Table1 inner join Table2 on Table1.KeyID = Table2.KeyID

I am only getting records that exists in both tables. How can I change
this query so that I will get all records from Table1 and all records
from Table2. Like this:


left outer join

(or just left join)
Jul 20 '05 #2
> I am doing a small database in ms access.

But you are posting in a Microsoft SQLServer newsgroup...
I am only getting records that exists in both tables. How can I change
this query so that I will get all records from Table1 and all records
from Table2. Like this:


It's called an OUTER join. Lookup OUTER JOINs in the Access help file:

SELECT Table1.Name, Table1.Major, Table2.GPA, Table2.Year
FROM Table1
LEFT JOIN Table2
ON Table1.KeyID = Table2.KeyID

--
David Portas
SQL Server MVP
--
Jul 20 '05 #3
Thank You Guys!!!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
2
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
4
by: bhbgroup | last post by:
I have a query on one large table. I only add one condition, i.e. a date (the SQL reads like 'where date > parameterdate'. This query is rather quick if 'parameterdate' is either explicitly...
8
by: Alfonso Esteban Gonzalez Sencion | last post by:
I am trying to use Access as a front end for extracting information from an Oracle database. I started using linked tables but I am getting a very curious behaviour. When I consult the linked...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
2
by: Arif | last post by:
Very strange problem: Executing my query against MS Access database using OleDbProvider for Access, I am getting the value for first two columns '0' instead of '1' in DataGrid. But if I connect to...
1
by: hardik | last post by:
hi friends i need help in this sql query i have table like, id fid __ _____ autonumber text and i am storing values like
4
by: Konrad Hammerer | last post by:
Hi! I have the following problem: I have a query (a) using another query (b) to get the amount of records of this other query (b), means: select count(MNR) as Number from...
13
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.