473,395 Members | 1,631 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,395 software developers and data experts.

Simple Problem with queries

1
Hello All,
I am fairly new to access, and have only a very cursory SQL query knowledge and I need some help.

I have two tables that have a single relationship. I have one table lets refer to it as "Main". I need to retain every record from main, but I am trying to "mux" in the information from the secondary table. If I run a simple query, combining the rows from main I need with the rows from secondary I need, all I get is the records from main that contain a value for the row that is used in the relationship. About 1/3 of main's records have no value, so the query generates a datasheet with about 2/3 of main's data.

I came up with a bad solution of just using a simple sql update statement to replace isNull isBlank with sometext and then just created a record in the secondary table that matches sometext. I realize this can't be the optimal way to do this, what would be?

My end goal is to condense all of the tables in this database into a flat file that I will eventually turn into a excel CSV file. So, hacky solutions that would not hold up for a long time in a real database don't bother me because I am really only doing this once to get the info out of the database.

Thank You,
H0bbes
May 12 '10 #1

✓ answered by bard777

You just need a RIGHT JOIN (or LEFT JOIN) instead of an INNER JOIN.

In the Query Design window for your query right click on the line between [Main] and [Mux] and choose properties. Then choose the option that say ALL RECORDS FROM [Main]. If you look at the SQL view it should look like the code below:

Expand|Select|Wrap|Line Numbers
  1. SELECT Main.f_1, Main.f_2, mux.d_1
  2. FROM mux RIGHT JOIN Main ON mux.mux_ID = Main.Main_ID;
or like this if you use a LEFT JOIN:

Expand|Select|Wrap|Line Numbers
  1. SELECT Main.f_1, Main.f_2, mux.d_1
  2. FROM Main LEFT JOIN mux ON Main.Main_ID = mux.mux_ID;

1 997
bard777
23
You just need a RIGHT JOIN (or LEFT JOIN) instead of an INNER JOIN.

In the Query Design window for your query right click on the line between [Main] and [Mux] and choose properties. Then choose the option that say ALL RECORDS FROM [Main]. If you look at the SQL view it should look like the code below:

Expand|Select|Wrap|Line Numbers
  1. SELECT Main.f_1, Main.f_2, mux.d_1
  2. FROM mux RIGHT JOIN Main ON mux.mux_ID = Main.Main_ID;
or like this if you use a LEFT JOIN:

Expand|Select|Wrap|Line Numbers
  1. SELECT Main.f_1, Main.f_2, mux.d_1
  2. FROM Main LEFT JOIN mux ON Main.Main_ID = mux.mux_ID;
May 12 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Smith | last post by:
Isn't life a bitch! You know what you want but you don't know how to get it. I have produced 12 queries that calculate a payment profile over 12 months. For a number of the records (ie with...
5
by: Steve Patrick | last post by:
Hi All You guys are my last hope, despite spending money on books and hours reading them I still can not achieve the results I need. I have designed a database in Access 2000 based on 1 table,...
5
by: kimberly.shaffer | last post by:
This may be a dumb question, but can you create a 1:M relationship with queries instead of tables? thanks!
2
by: Janelle.Dunlap | last post by:
I have a table in my database that is linked to an excel spreadsheet. I need to be able to manipulate the data in this linked table so that I can create smaller normalized tables that work with...
3
by: Janelle.Dunlap | last post by:
I have a table in my database that is linked to an excel spreadsheet. I need to be able to manipulate the data in this linked table so that I can create smaller normalized tables that work with...
2
by: MOSES | last post by:
How do i write simpe SQL queries using Access?
2
by: johnmay1248 | last post by:
I am having a problem with queries running in this code When I use the query "SELECT * FROM sample" the code runs and the data grid binds and shows the contents of the sample table. If I change...
1
by: kfboren | last post by:
I am running Access 2007, OS Vista. I am wondering if someone can help me. I have created 10 tables, 10 queries for the tables and 10 reports from the quearies. The creteria for the queries is the...
8
by: buncey | last post by:
Hi I have a number of standard queries based on a primary table. I have created various forms with embedded macros to filter out the information required. The bit that I can't work out is,...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.