473,671 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Perso n
FROM People INNER JOIN People_Language Skills ON People.ID_Perso n =
People_Language Skills.ID_Perso n
WHERE (((People_Langu ageSkills.ID_La nguage)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_Langu ageSkills.ID_La nguage)=[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_Language skills table who have both languages:)

I have tried to select from only the People_Language skills 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 1644
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_Perso n
FROM People INNER JOIN People_Language Skills ON People.ID_Perso n =
People_Language Skills.ID_Perso n
WHERE (((People_Langu ageSkills.ID_La nguage)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_Langu ageSkills.ID_La nguage)=[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_Language skills table who have both languages:)

I have tried to select from only the People_Language skills 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_Language Skills.ID_Langu age=[Forms]![Form1]![Combo22]
OR People_Language Skills.ID_Langu age=[Forms]![Form1]![Combo32]

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

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

iQA/AwUBQHwsLoechKq OuFEgEQKqNgCgxS XpTCSr8ioRfZfZp SADM2p7OpwAn22o
FQ0goSQ+fJuIEYo weafEuK0m
=8+DL
-----END PGP SIGNATURE-----

Nov 12 '05 #2
Jenni,

You need to add People_Language Skills 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_Perso n
FROM (People INNER JOIN People_Language Skills AS Language1
ON People.ID_Perso n = Language1.ID_Pe rson)
INNER JOIN People_Language Skills AS Language2
ON People.ID_Perso n = Language2.ID_Pe rson
WHERE Language1.ID_La nguage = [Forms]![Form1]![Combo22]
AND Language2.ID_La nguage=[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******** *************@n ews.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_Perso n
FROM People INNER JOIN People_Language Skills ON People.ID_Perso n =
People_Language Skills.ID_Perso n
WHERE (((People_Langu ageSkills.ID_La nguage)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_Langu ageSkills.ID_La nguage)=[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_Language skills table who have both languages:)

I have tried to select from only the People_Language skills 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_Perso n
FROM People INNER JOIN People_Language Skills ON People.ID_Perso n =
People_Language Skills.ID_Perso n
WHERE (((People_Langu ageSkills.ID_La nguage)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_Langu ageSkills.ID_La nguage)=[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_Language skills table who have both languages:)

I have tried to select from only the People_Language skills 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:Dc ount("ID","Peop le_LanguageSkil ls","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_Perso n 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_Perso n
FROM People INNER JOIN People_Language Skills ON People.ID_Perso n =
People_Language Skills.ID_Perso n
WHERE People_Language Skills.ID_Langu age)=[Forms]![Form1]![Combo22]
OR People_Language Skills.ID_Langu age)=[Forms]![Form1]![Combo32]
Group By People.ID_Perso n
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_Perso n
FROM People INNER JOIN People_Language Skills ON People.ID_Perso n =
People_Language Skills.ID_Perso n
WHERE (((People_Langu ageSkills.ID_La nguage)=[Forms]![Form1]![Combo22]));

The moment I add
AND (((People_Langu ageSkills.ID_La nguage)=[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_Language skills table who have both languages:)

I have tried to select from only the People_Language skills 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
1501
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 some Java code running on the phone at a fairly low transaction rate. There will also be a simple web site allowing users to edit preferences and so forth. I have just enough Python experience to decide that I prefer it over Java for this job. It'll...
0
3062
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 solve my problem. I'll turn to MySQL doc after getting through this pressing project. Thanks a lot Roger! Babale -----Urspr=FCngliche Nachricht-----
2
1946
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 that needs to "left" join to table1A, table1B, and table1C which is corrently done with the following: select table1.x, table1a.y, table1b.z, table1c.q from table1 left join table1a on table1.ID = table1a.ID left join table1b on table1.ID =...
3
3347
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 inner joins, as follows : SELECT DISTINCT upcards.id,statuskey.status,upcards.firstname,upcards.lastname,originkey.ori gin,associatekey.username,associatekey2.username,upcards.deleted FROM upcards,status,origins,associates INNER JOIN status...
1
2266
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 TCDomain_1, TMS.CaseF.Name AS TCFolder_2, TMS_CaseF_1.Name AS TCFolder_3,
8
4968
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 also display their corresponding entries in arb, but if there is NO entry in arb I still want it to show up as NULL or something, so that I can get the attention that there IS no language associated with that article.
7
1676
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 was happening and just don't get it yet. Here's the starting query (reduced to simple prefixes): ----INITIAL-----
12
18665
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 LEFT JOIN UserTeamAssoc UTA ON UTA.userID = U.userID, Role R, UserRoleAssoc URA, Team T WHERE U.userID = URA.userID AND URA.roleID = R.roleID AND U.userId > 1
4
262
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 (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.
52
6314
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 variations(combination of fields), - then act on each group in some way ...eg ProcessRs (oRs as RecordSet)... the following query will get me the distinct groups
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8824
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8603
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6236
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2818
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.