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

Access Left Joins


I'm working with access 2000 and I can't seem to get the query
working:

SELECT users.fullname, country.country, state.state
FROM users, user_countries, country
LEFT JOIN states ON user_countries.state_id = states.state_id
WHERE users.user_id = 1
AND users.user_id = user_countries.user_id
AND user_countries.country_id = country.country_id
country
--------
country_id
country

states
--------
state_id
country_id
state
user_countries
-------
user_id
country_id
state_id
( ** a user will always have a country id but not always a state_id,
state_id might be NULL **)
users
-----
user_id
fullname

I would like to return the following results:

Full Name,Country,State
------------------------
Adam Smith, United States, CA
Bob Smith, Canada, ON
David Smith, Mexico, NULL
Thanks for your help

Apr 16 '07 #1
1 1828
On Apr 16, 2:29 pm, "carrajo" <carraz...@gmail.comwrote:
I'm working with access 2000 and I can't seem to get the query
working:

SELECT users.fullname, country.country, state.state
FROM users, user_countries, country
LEFT JOIN states ON user_countries.state_id = states.state_id
WHERE users.user_id = 1
AND users.user_id = user_countries.user_id
AND user_countries.country_id = country.country_id

country
--------
country_id
country

states
--------
state_id
country_id
state

user_countries
-------
user_id
country_id
state_id
( ** a user will always have a country id but not always a state_id,
state_id might be NULL **)

users
-----
user_id
fullname

I would like to return the following results:

Full Name,Country,State
------------------------
Adam Smith, United States, CA
Bob Smith, Canada, ON
David Smith, Mexico, NULL

Thanks for your help
Maybe:

SELECT users.fullname, country.country, states.state FROM ((users
INNER JOIN user_countries ON users.user_id = user_countries.user_id)
LEFT JOIN states ON user_countries.state_id = states.state_id) INNER
JOIN country ON user_countries.country_id = country.country_id WHERE
users.user_id=1;

James A. Fortune
CD********@FortuneJames.com

Apr 16 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
7
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
3
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
3
by: Jon Ole Hedne | last post by:
My Access 2002-application need to work with tables from both Oracle and Access. To solve this, I want to run some querys on three views in Oracle and import the results into temporary...
12
by: Phil Powell | last post by:
<cfquery name="getAll" datasource="#request.dsn#"> SELECT U.userID, U.fname, U.lname, U.phone, U.lastLoggedIn, U.choiceId, U.experience, T.label AS teamLabel, R.label AS roleLabel FROM User U...
3
by: deko | last post by:
From what I understand, an Inner Join narrow the rows selected to the table with the least results... and an Outer Join does the opposite... SELECT qryTxToQ1.Q1Total, qryTxToQ2.Q2Total,...
9
by: Alan Lane | last post by:
Hello world: Background: Yesterday, January 21, Doug Steele was kind enough to help me out on a Left Join problem. I was trying to return all stores and their Gross Adds for December, 2004...
42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
10
by: Hank | last post by:
We have just recently migrated the data from our Access 2000 backend to Postgres. All forms and reports seem to run correctly but, in many cases, very slowly. We do not want to switch over until...
19
by: Tim Marshall | last post by:
Hi everyone, I have an acquaintance who is doing some A2003 development who was asking a question on another forum (not a technical one) about an SQL problem he's having. As far as I can...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.