473,407 Members | 2,598 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,407 software developers and data experts.

Combining 2 tables in access where data in one table is subset of other

I have 2 tables with following fields:

Table A
Customer_ID
Sales
Statecode

TableB
Customer_ID
Discount

Table A has something like 200 Customer IDs out of which about 50 Customer IDs also have a discount amount associated with them.

I now want to create a Master Table of 200 customers where I can have all the 4 fields, i.e. Customer_ID, Sales, Statecode and Discount. For those customers who didn’t get any discount, I want a null value in the Discount field.

However if I link the tables using a query, only the customers common on both the tables get selected. Could someone please help me out here.

Regards,
Sagar
Aug 4 '10 #1

✓ answered by Darren McDonald

Use a left join, ie all fields from tableA and only field from TableB where Customer_ID are equal.

Use a iif statement for the discount

iif(isnull(Discount),0,discount)

5 2974
Use a left join, ie all fields from tableA and only field from TableB where Customer_ID are equal.

Use a iif statement for the discount

iif(isnull(Discount),0,discount)
Aug 4 '10 #2
thanks! This did the trick.
Aug 4 '10 #3
NeoPa
32,556 Expert Mod 16PB
I suspect this is due to your query joining the two tables with an INNER JOIN rather than the LEFT JOIN which would be required for your needs. See SQL JOINs for more details of this.
Aug 4 '10 #4
This is very helpful. Thanks!

I indeed did not know about various types of joins before today.
Aug 4 '10 #5
NeoPa
32,556 Expert Mod 16PB
You're welcome Sagar :) Learning new things is always fun.
Aug 4 '10 #6

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

Similar topics

2
by: diadia | last post by:
when i write two classes as follow . compiler tell me that i can't access private number from other class but if types of two classes are the same it don't have error message ? why? class...
2
by: Colin Graham | last post by:
I have a little problem i was wondering if anyone could help. I have created a table in Access and it has the following format. UniqueID FieldResult 100 1,3,5,7,23,7,8,9,12,4 103 ...
4
by: intl04 | last post by:
How do I create a data input form in Access that is external to the Access database to which it's connected (if that's possible, which I believe it is)? For example, if someone clicks on an Access...
2
by: resti | last post by:
hi is there any code that i can use to access my table in ms access databas example i want to add employee data on employee tabl edit employee dat delete employee dat help me pls thanks,
0
by: rose | last post by:
I have an ACCESS graph and when I turn on show data tables, the data table displays a whole number instead of the percentage like the graph. I have formatted the sourc query to be percentage, but I...
3
by: jaidev | last post by:
I am creating backup and restore facility for my access based program, backup is working fine where I simply extract tables to another database. While restoring the same I would like to check...
1
by: Rinoa | last post by:
Hi, I have a very large spreadsheet that I am trying to import to an access database. One of the worksheets is 28 columns and 3500 rows. I'm importing it to a table titled tblFlyingJEStock. I'm...
4
by: wideasleep | last post by:
Hello, I have a situation where I have been asked to combine two tables and make a form to continue to enter data. I have created a relationship between the tables and have gotten to creating the...
1
by: nspader | last post by:
I am working on a new DB for something that clearly has not been done yet. As I have been able to find nothing on it. However, I need to start from the begining and I am having trouble setting up...
4
by: xperre van wilrijk | last post by:
Hi, I have inherited an access userinterface that links to sql server tables through ODBC. The SQL server database contains data related to villages in my country and is populated by my...
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: 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:
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.