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

Select records that appear in any one or more of three tables

Hello,

I'm so stuck and this seems like it should be so simple.

I have three tables, called Auction Items, Party #1 and Party #2. A bidder number may appear in one, two or all three of them. I'm trying to write a query that will select distinct bidder numbers that appear in one (or more) of the tables. I've found several pieces of code and tried to alter them, to no avail. The Winning Bidder Number field is the only thing I need from each table.

The code says error in From Clause, but I can't find anything wrong from what I copied from Microsoft's web site. When I created an exact duplicate of their example, it still said that. I also haven't tried to add in the Party #2 table since I couldn't get it to work with just the first one. Here it is:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT [Auction Items].[Winning Bidder Number], [Party #1].[Winning Bidder Number]
  2.  
  3. FROM {oj Auction Items LEFT OUTER JOIN ON [Auction Items].[Winning Bidder Number] = [Party #1].[Winning Bidder Number]}
  4.  
  5. UNION SELECT DISTINCT [Auction Items].[Winning Bidder Number],
  6.  
  7. FROM {oj Auction Items LEFT OUTER JOIN [Party #1] ON [Auction Items].[Winning Bidder Number] =[Party #1].[Winning Bidder Number]}
  8.  
Any help would be most appreciated.
Jan 3 '08 #1
5 1604
Rabbit
12,516 Expert Mod 8TB
Please use code tags.

I don't know if you can use { } curly brackets to group a clause. Try using parentheses.

If you have an object name with spaces, you must enclose it with [ ] square brackets.

I don't think your union query will work as it has different amounts of columns. I believe union queries require the same amount of columns.
Jan 3 '08 #2
Thanks for the reply. I apologize--but I don't know what code tags are. I see something on the reply guidelines--does that mean just to put
Expand|Select|Wrap|Line Numbers
  1.  at the beginning and 
at the end?

I changed the curly braces to parentheses, and now my error says syntax error in join operation.

I'd be more than glad to throw this code out if there is something that will work better. I have so little experience I just didn't know where to start.
Jan 3 '08 #3
Rabbit
12,516 Expert Mod 8TB
Yes that is indeed the code tags.

I think you're overcomplicating things. Try:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT [Winning Bidder Number]
  2. FROM [Auction Items]
  3. UNION
  4. SELECT DISTINCT [Winning Bidder Number]
  5. FROM [Party #1]
  6. UNION
  7. SELECT DISTINCT [Winning Bidder Number]
  8. FROM [Party #2];
  9.  
Jan 3 '08 #4
Thank you! That's it exactly. I had expected it to be simple, but my knowledge is so limited and I don't get that many chances to improve it with everything else I do, so I pretty much have to find an example somewhere and modify. Thanks again!
Jan 3 '08 #5
Rabbit
12,516 Expert Mod 8TB
Not a problem, good luck.
Jan 3 '08 #6

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

Similar topics

4
by: Denis St-Michel | last post by:
Hello All, Hope some Guru will be able to help me with this. Let's take this example table A ------------------------------------------------------------------------------- id | ...
6
by: Michael | last post by:
I have two tables with a 1-many relationship. I want to write a select statement that looks in the table w/many records and compares it to the records in the primary table to see if there are any...
5
by: David Logan | last post by:
Hello, I am trying to construct a query across 5 tables but primarily 3 tables. Plan, Provider, ProviderLocation are the three primary tables the other tables are lookup tables for values the...
7
by: Eric Slan | last post by:
Hello All: I'm having a problem that's been baffling me for a few days and I seek counsel here. I have an Access 2000 DB from which I want to run several reports. These reports are...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
1
by: plaforest | last post by:
Hello All, Thank you for your thoughtful consideration. I am running Access 2000 (9.0.3821 SR-1) This query works: SELECT , FROM table1
5
by: Neil | last post by:
I'm running Access 2000 with a SQL 7 back end, using ODBC linked tables in an MDB file. The db is used by about 30 users on a LAN, and an additional 10 or so on a WAN. Recently, one of the WAN...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
2
by: Steve | last post by:
I have zero experience with ODBC. If I have an Access frontend connected to a SQL Database using ODBC, are the tables connected like a frontend/backend Access database where the the tables you see...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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?
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...

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.