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

SQL - join hassle?

Hi all,

Sorry to hassle you with this query, I'm sure the answer is a simple
one, but it remains elusive - to me anyway.

What I am trying to do is get a query to work. I have a table of people
(with ID's) and a table of languages (with People IDs and Language IDs).
Now one person may speak many languages. I have put in the relationship.
What I want is to be able to say pull out all the people wjo speak these
3 languages.

The query I manage to make is this

SELECT DISTINCT People.ID_Person
FROM People INNER JOIN People_LanguageSkills ON People.ID_Person =
People_LanguageSkills.ID_Person
WHERE (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo32]))

It stops working. It now says that no-one speaks English (ID 1) and
French (ID 3). I have checked to make sure that there are people in the
People_Languageskills table who have both languages:)

I have tried to select from only the People_Languageskills table and
from the joined tables as above.

What am I doing wrong????

Thanks in advance

Jenni

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
5 1629
Jenni wrote:
Hi all,

Sorry to hassle you with this query, I'm sure the answer is a simple
one, but it remains elusive - to me anyway.

What I am trying to do is get a query to work. I have a table of people
(with ID's) and a table of languages (with People IDs and Language IDs).
Now one person may speak many languages. I have put in the relationship.
What I want is to be able to say pull out all the people wjo speak these
3 languages.

The query I manage to make is this

SELECT DISTINCT People.ID_Person
FROM People INNER JOIN People_LanguageSkills ON People.ID_Person =
People_LanguageSkills.ID_Person
WHERE (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo32]))

It stops working. It now says that no-one speaks English (ID 1) and
French (ID 3). I have checked to make sure that there are people in the
People_Languageskills table who have both languages:)

I have tried to select from only the People_Languageskills table and
from the joined tables as above.

What am I doing wrong????


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
It should be OR instead of AND:

WHERE People_LanguageSkills.ID_Language=[Forms]![Form1]![Combo22]
OR People_LanguageSkills.ID_Language=[Forms]![Form1]![Combo32]

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQHwsLoechKqOuFEgEQKqNgCgxSXpTCSr8ioRfZfZpSADM2 p7OpwAn22o
FQ0goSQ+fJuIEYoweafEuK0m
=8+DL
-----END PGP SIGNATURE-----

Nov 12 '05 #2
Jenni,

You need to add People_LanguageSkills to the query once for every language
you want to compare. Your query will look something like this (I haven't
tested it):

SELECT DISTINCT People.ID_Person
FROM (People INNER JOIN People_LanguageSkills AS Language1
ON People.ID_Person = Language1.ID_Person)
INNER JOIN People_LanguageSkills AS Language2
ON People.ID_Person = Language2.ID_Person
WHERE Language1.ID_Language = [Forms]![Form1]![Combo22]
AND Language2.ID_Language=[Forms]![Form1]![Combo32]

The query builder will write the SQL if you can draw the joins properly.

Also, FYI, there are other ways to approach this problem. You can, for
instance, construct a system which lets you match on a variable number of
languages (instead of hard-coding exactly 3), and there are ways to avoid
referencing forms from your queries.
-Todd Matson
"Jenni" <je***@khul.com> wrote in message
news:40*********************@news.frii.net...
Hi all,

Sorry to hassle you with this query, I'm sure the answer is a simple
one, but it remains elusive - to me anyway.

What I am trying to do is get a query to work. I have a table of people
(with ID's) and a table of languages (with People IDs and Language IDs).
Now one person may speak many languages. I have put in the relationship.
What I want is to be able to say pull out all the people wjo speak these
3 languages.

The query I manage to make is this

SELECT DISTINCT People.ID_Person
FROM People INNER JOIN People_LanguageSkills ON People.ID_Person =
People_LanguageSkills.ID_Person
WHERE (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo32]))

It stops working. It now says that no-one speaks English (ID 1) and
French (ID 3). I have checked to make sure that there are people in the
People_Languageskills table who have both languages:)

I have tried to select from only the People_Languageskills table and
from the joined tables as above.

What am I doing wrong????

Thanks in advance

Jenni

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3
Jenni wrote:
Hi all,

Sorry to hassle you with this query, I'm sure the answer is a simple
one, but it remains elusive - to me anyway.

What I am trying to do is get a query to work. I have a table of people
(with ID's) and a table of languages (with People IDs and Language IDs).
Now one person may speak many languages. I have put in the relationship.
What I want is to be able to say pull out all the people wjo speak these
3 languages.

The query I manage to make is this

SELECT DISTINCT People.ID_Person
FROM People INNER JOIN People_LanguageSkills ON People.ID_Person =
People_LanguageSkills.ID_Person
WHERE (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo32]))

It stops working. It now says that no-one speaks English (ID 1) and
French (ID 3). I have checked to make sure that there are people in the
People_Languageskills table who have both languages:)

I have tried to select from only the People_Languageskills table and
from the joined tables as above.

What am I doing wrong????

Thanks in advance

Jenni

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
A ; (semi-colon) ends a SQL statement. Are you appending the Combo32
line to the end of an existing SQL statement?

If you wanted a count of languages >= 3, you might want to consider
using DCount()
NumLanguages:Dcount("ID","People_LanguageSkills"," ID = " & [ID])
and substitute ID with your field name and in the criteria row enter2


Nov 12 '05 #4
The problem is that a single record cannot be both English and French.
It needs to be an OR criteria, however this won't return the results
you are looking for because you will get every person who speaks
english or french instead of English and French. So the work around
is to use the OR and then use a Group By with a Count of
People.ID_Person and only display the records where the
Count(People.ID_Person) is equal to the number of language skills you
are looking for.

SELECT DISTINCT People.ID_Person
FROM People INNER JOIN People_LanguageSkills ON People.ID_Person =
People_LanguageSkills.ID_Person
WHERE People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo22]
OR People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo32]
Group By People.ID_Person
HAVING Count(People.ID_Person)=2;

Jenni <je***@khul.com> wrote in message news:<40*********************@news.frii.net>...
Hi all,

Sorry to hassle you with this query, I'm sure the answer is a simple
one, but it remains elusive - to me anyway.

What I am trying to do is get a query to work. I have a table of people
(with ID's) and a table of languages (with People IDs and Language IDs).
Now one person may speak many languages. I have put in the relationship.
What I want is to be able to say pull out all the people wjo speak these
3 languages.

The query I manage to make is this

SELECT DISTINCT People.ID_Person
FROM People INNER JOIN People_LanguageSkills ON People.ID_Person =
People_LanguageSkills.ID_Person
WHERE (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_LanguageSkills.ID_Language)=[Forms]![Form1]![Combo32]))

It stops working. It now says that no-one speaks English (ID 1) and
French (ID 3). I have checked to make sure that there are people in the
People_Languageskills table who have both languages:)

I have tried to select from only the People_Languageskills table and
from the joined tables as above.

What am I doing wrong????

Thanks in advance

Jenni

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #5
Hi Todd,

I havnt been working with this since way back when, but I would love to
know how to reference a variable number of languages, and to do it
without referencing the form would be fantastic. I am a novice VB
developer, but find that I cant reference things in code in Access the
same way that I can in VB, which is very frustrating. I'd love to get
the info on the above.

Thanks,

Jenni

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #6

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

Similar topics

7
by: kanzen | last post by:
I keep telling my friends that Python rocks. Now it's time to put my money where my mouth is. I'm about to start writing a server for a phone based game. It needs to handle simlpe requests from...
0
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me...
2
by: Bruce Duncan | last post by:
I'm a bit new to MySQL (know MS SQL well...and that may be the problem...getting the syntax confused) and I'm having a join problem...can anyone offer some help? Here's my problem: I have table1...
3
by: Ike | last post by:
Oh I have a nasty query which runs incredibly slowly. I am running MySQL 4.0.20-standard. Thus, in trying to expedite the query, I am trying to set indexes in my tables. My query requires four...
1
by: Beachvolleyballer | last post by:
hi there anyone had an idea to join following 2 queries to 1???? ----- QUERY 1 --------------------------------------------- SELECT TMS_CaseF_2.Name AS TCDomain_0, TMS_CaseF_3.Name AS...
8
by: Matt | last post by:
Hello I have to tables ar and arb, ar holds articles and a swedish description, arb holds descriptions in other languages. I want to retreive all articles that match a criteria from ar and...
7
by: Greg | last post by:
I'm a quantitative securities analyst working with Compustat data (company fiscal reports and pricing feeds). My coworker came across a problem that we fixed, but I'd like to understand 'why' it...
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...
4
by: Jenni | last post by:
Hi all, Sorry to hassle you with this query, I'm sure the answer is a simple one, but it remains elusive - to me anyway. What I am trying to do is get a query to work. I have a table of people...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
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
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?
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.