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

joining multiple tables based on 1 criteria

Apparently, Im incapable of properly executing this query! I've been at this for far too long and gotten nowhere. Forgive me if this is a umb mistake; I'm not great at SQL.

I've got three tables, MASTER, RETAIL, and AUDIT... MASTER and RETAIL have the same fields, except each record has a unique ITEMNO, and master's numbers are positive and retail's are negative. AUDIT contains some of both table's item numbers in it. I just want to join audit to both tables based on the ITEMNO, (Audit's ITEMNO field is actually called MMNO, if that matters) I can JOIN one or the other and it'll show up with the right fields, but when I try to join both it returns with no records. I know I'm messing up, I just don't know how to fix it.

This is what I've got (take out either master OR retail and it works fine):
SELECT AUDIT.TRANSACTIONNO,AUDIT.DATIM, AUDIT.MMNO, AUDIT.COPYS, AUDIT.PRICE,
MASTER.ITEMNO, MASTER.MTITLE, MASTER.MSRP,
RETAIL.ITEMNO, RETAIL.MTITLE, RETAIL.MSRP,
FROM BUYBACKAUDIT
JOIN RETAIL ON AUDIT.ITEMNO=RETAIL.MMBSNO
JOIN MASTER ON AUDIT.ITEMNO=MASTER.MMBSNO

Any help would be much appreciated. Thanks!
Jul 31 '08 #1
4 2459
ck9663
2,878 Expert 2GB
What's in AUDIT? Positive or Negative? or both?

-- CK
Jul 31 '08 #2
both. So I want to see what item numbers are in AUDIT and match them to the master and retail records accordingly.
Jul 31 '08 #3
ck9663
2,878 Expert 2GB
Use left join on both, instead of inner join

-- CK
Jul 31 '08 #4
Hi

use the following query

SELECT AUDIT.TRANSACTIONNO,AUDIT.DATIM, AUDIT.MMNO, AUDIT.COPYS, AUDIT.PRICE,
MASTER.ITEMNO, MASTER.MTITLE, MASTER.MSRP,
RETAIL.ITEMNO, RETAIL.MTITLE, RETAIL.MSRP,
FROM BUYBACKAUDIT AUDIT
LEFT OUTER JOIN RETAIL ON AUDIT.ITEMNO=RETAIL.MMBSNO
LEFT OUTER JOIN MASTER ON AUDIT.ITEMNO=MASTER.MMBSNO

Thanks
Nathan
Hyper Drive
Bangalore
Aug 4 '08 #5

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

Similar topics

1
by: TH | last post by:
I am (still :) working on a recipe database. Now I am trying to figure out how to set it up for an ingredient search. What I want it to be able to do is three things: 1. Search based on just...
4
by: Gobi | last post by:
Hello, I have a Database with lists of Clients in each. Every year a new tables is created with the naming convention "CloseYear" ie close1999, close2000 There are tables from this year back to...
3
by: Bob C. | last post by:
When I migrated my tables to SQL Server I needed a way to overcome the slow performance of the Find method on my recordsets. Although this can be done by accessing the table directly using dao and...
2
by: DraguVaso | last post by:
Hi, I found some examples for storing the FormSettings of a Form in an XML-file, but none of these could match my criteria: What I am looking for is the possibility to save the FormSettings of...
1
by: davidevan | last post by:
What I'm trying to do is set a players division according to their age. So if age is 8, update division to junior, if age is 9, update division to medium, if age is 10, update division to pee wee,...
7
by: Ceebaby via AccessMonster.com | last post by:
Hi All Here's hoping someone can help me with this. I have a report based on a query where the criteria for 4 of the fields is set from an unbound form. I want the user to be able to select any...
0
by: redpears007 | last post by:
Morning all! :) I have a database with multiple linked tables. I have created a search form with one txt box, for entering search criteria, and a listbox for each of the tables to isplay the...
3
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
1
by: jcf378 | last post by:
Hi all-- Does anyone have any insight as to how I might create a search form that allows a user to select criteria based on any related table in the whole database. The search form I have now only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.