473,387 Members | 3,781 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,387 software developers and data experts.

Query help

I've been too far away from SQL for too long doing other-level things and my
ancient addled brain isn't what it once was.

Here's the deal:
My wife is doing a small app in Access. I know zippo about Access and any
peculiarities it may have - nor do I want to learn anything about this
particular piece of Microsft virusware. Needless to say, she's asking me
loads of questions.

She's trying to keep track of all addresses used by various people, and also
needs to ensure that each person has at least one address (there is a null
address available for those people who she doesn't have full details for at
the time of original data input).

That said, this isn't strictly a question about Access (97 in her case). I'm
just trying to see if I'm bumping into a limitation in the version of Access
regarding outer joins or whether my brain is simply on stun mode these days
vis. SQL-92.

The data model I'm working with looks like the following:

Person Address
| |
|-->PersonAddress<---|
^
|
AddressType

I'm using surrogate keys (autonumber) for all tables. Sample instance data
appears below (assume all attributes are nullable) along with the desired
query results:
Person Table
PersonPK fname lname
1 Tom Sawyer
2 Huck Finn
3 Eric Clapton
4 Louis Armstrong
5 George Bush
6 Kevin Bacon
7 Buffalo Bob
Address Table (all ficitious)
AddressPK street city state
1 2200 Your Street Mudhole MO
2 8 My Street Boston MA
3 461 Ocean Blvd Miami FLA
4 10 His Street New York NY
5 1600 Pennsylvania Washington D.C
6 R.R. 5 Dustbowl TX
7 Fort Leavenworth Leavenworth KS
8 100 Dow Way Midland MI
9 256 Chemical Way Ann Arbor MI
10 null null
null
AddressType Table
AddressTypePK desc
1 home
2 work
3 vacation
4 prison
5 other
PersonAddress Table
personPK addressPK addressTypePK
1 1 1
2 1 1
3 2 1
3 3 3
4 4 1
5 5 2
5 6 1
5 7 4
6 8 1
6 9 2
7 10 5
Desired results of the query
====================
fname lname street city
state desc
Tom Sawyer 2200 Your Street Mudhole MO home
Huck Finn 2200 Your Street Mudhole MO
home
Eric Clapton 8 My street Boston MA
home
Eric Clapton 461 Ocean Blvd Miami FLA
vacation
Louis Armstrong 10 His Street New York NY
home
George Bush 1600 Pennsylvania Washington D.C work
George Bush R.R.5 Dustbowl TX
home
George Bush Fort Leavenworth Leavenworth KS prison
Kevin Bacon 100 Dow Way Midland MI
work
Kevin Bacon 256 Chemical Way Ann Arbor MI home
Buffalo Bob null null
null other
(sorry about the wrapping)

Clearly there is a left outer join involved in order to return Buffalo Bob
with no known address.

Right now I'm stumped. I know that I'm capable of figuring this out in the
remaing time the universe has left to exists, but that would just make me
plain ordinary stupid. So I prefer to claim that I have Alzheimer's and thus
I'm not responsible for my stupidity. It may be a fine distinction but it's
one I have to invoke.

Anything you can do to help clear the cobwebs from my brain are appreciated.


Nov 12 '05 #1
1 2024
Seems you are doing fine.
Have just spent 5 minutes writing a micky mose version. If you want I will
e-mail it to you

Phil

"John Smith" <a@nonymous.com> wrote in message
news:HP*******************@news04.bloor.is.net.cab le.rogers.com...
I've been too far away from SQL for too long doing other-level things and my ancient addled brain isn't what it once was.

Here's the deal:
My wife is doing a small app in Access. I know zippo about Access and any
peculiarities it may have - nor do I want to learn anything about this
particular piece of Microsft virusware. Needless to say, she's asking me
loads of questions.

She's trying to keep track of all addresses used by various people, and also needs to ensure that each person has at least one address (there is a null
address available for those people who she doesn't have full details for at the time of original data input).

That said, this isn't strictly a question about Access (97 in her case). I'm just trying to see if I'm bumping into a limitation in the version of Access regarding outer joins or whether my brain is simply on stun mode these days vis. SQL-92.

The data model I'm working with looks like the following:

Person Address
| |
|-->PersonAddress<---|
^
|
AddressType

I'm using surrogate keys (autonumber) for all tables. Sample instance data
appears below (assume all attributes are nullable) along with the desired
query results:
Person Table
PersonPK fname lname
1 Tom Sawyer
2 Huck Finn
3 Eric Clapton
4 Louis Armstrong
5 George Bush
6 Kevin Bacon
7 Buffalo Bob
Address Table (all ficitious)
AddressPK street city state
1 2200 Your Street Mudhole MO
2 8 My Street Boston MA
3 461 Ocean Blvd Miami FLA
4 10 His Street New York NY
5 1600 Pennsylvania Washington D.C
6 R.R. 5 Dustbowl TX 7 Fort Leavenworth Leavenworth KS
8 100 Dow Way Midland MI
9 256 Chemical Way Ann Arbor MI
10 null null
null
AddressType Table
AddressTypePK desc
1 home
2 work
3 vacation
4 prison
5 other
PersonAddress Table
personPK addressPK addressTypePK
1 1 1
2 1 1
3 2 1
3 3 3
4 4 1
5 5 2
5 6 1
5 7 4
6 8 1
6 9 2
7 10 5
Desired results of the query
====================
fname lname street city
state desc
Tom Sawyer 2200 Your Street Mudhole MO home
Huck Finn 2200 Your Street Mudhole MO
home
Eric Clapton 8 My street Boston MA
home
Eric Clapton 461 Ocean Blvd Miami FLA
vacation
Louis Armstrong 10 His Street New York NY
home
George Bush 1600 Pennsylvania Washington D.C work
George Bush R.R.5 Dustbowl TX
home
George Bush Fort Leavenworth Leavenworth KS prison
Kevin Bacon 100 Dow Way Midland MI
work
Kevin Bacon 256 Chemical Way Ann Arbor MI home
Buffalo Bob null null
null other
(sorry about the wrapping)

Clearly there is a left outer join involved in order to return Buffalo Bob
with no known address.

Right now I'm stumped. I know that I'm capable of figuring this out in the remaing time the universe has left to exists, but that would just make me
plain ordinary stupid. So I prefer to claim that I have Alzheimer's and thus I'm not responsible for my stupidity. It may be a fine distinction but it's one I have to invoke.

Anything you can do to help clear the cobwebs from my brain are appreciated.

Nov 12 '05 #2

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

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
7
by: Simon Bailey | last post by:
How do you created a query in VB? I have a button on a form that signifies a certain computer in a computer suite. On clicking on this button i would like to create a query searching for all...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
4
by: Alan Lane | last post by:
Hello world: I'm including both code and examples of query output. I appologize if that makes this message longer than it should be. Anyway, I need to change the query below into a pivot table...
36
by: Liam.M | last post by:
hey guys, I have one last problem to fix, and then my database is essentially done...I would therefore very much appreciate any assistance anyone would be able to provide me with. Currently I...
5
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the...
10
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
4
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice...
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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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:
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
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...

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.