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

Joining 2 tables in Access query.

I have 2 tables - 'Nurseries' with nursery name and address info, and 'Zip' with 2 fields -zip1 and zip2. Zip1 are unique (but multiple) values and zip2 are zip codes with an area around zip1. Example:
zip1 zip2
-----------------
94041 94036
94041 94303
94041 95051
94041 95054
... etc.

When the user enters a zip code (like 94041), I'm trying to get a list of nurseries with zip codes in the zip2 list.

I've tried inner joins and right and left joins, and with each I get syntax errors. Example of code:

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM Nurseries
  3. INNER JOIN Zip
  4. ON nurseries.zip = zip.zip2
  5. WHERE nurseries.zip IN (SELECT zip.zip2 WHERE zip.zip1 = '[Enter zip:]);
  6.  
Any help would be greatly appreciated.
Jul 20 '15 #1

✓ answered by jforbes

This should probably do it. I just typed it in, so beware of typos.

You would want to Query on the Zip you have, then get a list of associated Zips and Nurseries that have that Zip.

Expand|Select|Wrap|Line Numbers
  1. SELECT Nurseries.*
  2. FROM Zip
  3. LEFT JOIN Nurseries
  4. ON Zip.Zip2=Nurseries.Zip
  5. WHERE Zip.Zip1=[TheZipYouAreQueryingOn]

2 920
jforbes
1,107 Expert 1GB
This should probably do it. I just typed it in, so beware of typos.

You would want to Query on the Zip you have, then get a list of associated Zips and Nurseries that have that Zip.

Expand|Select|Wrap|Line Numbers
  1. SELECT Nurseries.*
  2. FROM Zip
  3. LEFT JOIN Nurseries
  4. ON Zip.Zip2=Nurseries.Zip
  5. WHERE Zip.Zip1=[TheZipYouAreQueryingOn]
Jul 21 '15 #2
Thanks for the reply. It does work, but I would get several blank lines between the nurseries listed in the dataset view. I tried changing the LEFT JOIN to a RIGHT JOIN and the resulting contained the same resulting nurseries with no blank line between.
Jul 21 '15 #3

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

Similar topics

5
by: anthonyberet | last post by:
I work for an organisation that uses a bespoke document imaging system, the database of which is an MS sql server. We have MS Access and already use it for some querying of the database. The...
5
by: Ciar?n | last post by:
I have about 7 tables I need to join, but am having a lot of difficulty with the joins, that I need some help on. I'll provide the details of four tables to illustrate the scenario. I have one...
11
by: DraguVaso | last post by:
Hi, I want to make a small application in VB.NET that relinks all the query's and tables in an Access database that are linked via ODBC to an SQL Server. It must be able to relink all the tables...
10
by: Captain Nemo | last post by:
Hi I'm working on an ASP project where the clients want to be able to effectively perform SELECT queries joining tables from two different databases (located on the same SQL-Server). Does...
8
by: s_wadhwa | last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber, UCASE(Buildings.BuildingName) AS BuildingName, Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
12
by: zwasdl | last post by:
Hi, I'm using MS Access to query against Oracle DB via ODBC. Is it possible to use HINT in Access? Thanks, Wei
1
by: nights | last post by:
hi! i'm just a newbie with php and mysql... and i'm having problems joining tables from different databases... can you please help me? here's my query: SELECT database1.table1.field1,...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
1
by: James Armstrong | last post by:
Hey guys I am trying to link from excel to an access query I created. The query I created in Access uses linked sql tables via odbc. When using excel's import external data tool I am able to log in...
13
by: Amr Ali | last post by:
I have a microsoft access database ver. 2003 with linked table to a huge csv file. This csv file is about 800 MB size what couldn't be imported to access by any way because each time I am trying to...
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?
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:
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
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
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.