473,811 Members | 2,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query question...

I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With fitting the profile
I mean that the user uses 1 to every App (but not more) of those that are in
the Profile table. In this case only user 1 and 3 fit the profile.

Can someone point me in the right direction?
Thanks!
john
Nov 24 '06 #1
13 1859
have you tried an Inner Join between the two tables in the query, linked
between the IDApp fields?

hth
"john" <jo**@test.comw rote in message
news:3v******** *************** *******@casema. nl...
I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With fitting the
profile
I mean that the user uses 1 to every App (but not more) of those that are
in
the Profile table. In this case only user 1 and 3 fit the profile.

Can someone point me in the right direction?
Thanks!
john


Nov 24 '06 #2
"john" <jo**@test.comw rote in
news:3v******** *************** *******@casema. nl:
I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With
fitting the profile I mean that the user uses 1 to every App
(but not more) of those that are in the Profile table. In this
case only user 1 and 3 fit the profile.

Can someone point me in the right direction?
Thanks!
john
paste this into the sql view of the query builder, it should
work.

SELECT IDuser,
count(User-App.IDApp) as x
FROM User-App
INNER JOIN [App Profile]
ON User-App.IDApp = [App Profile].IDApp
HAVING count(User-App.IDApp) = dCount("IdApp", "[App Profile]")
GROUP BY IDUser;

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 24 '06 #3
Thanks Bob,
Unfortunately I keep getting an error on:
HAVING count(User-App.IDApp) = dCount("IdApp", "[App Profile]")
I tried every possible quoting and also tried replacing , in ; but I keep
getting a syntax error.
Any idea what's causing this?
john

"Bob Quintal" <rq******@sPAmp atico.caschreef in bericht
news:Xn******** **************@ 66.150.105.47.. .
"john" <jo**@test.comw rote in
news:3v******** *************** *******@casema. nl:
>I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With
fitting the profile I mean that the user uses 1 to every App
(but not more) of those that are in the Profile table. In this
case only user 1 and 3 fit the profile.

Can someone point me in the right direction?
Thanks!
john
paste this into the sql view of the query builder, it should
work.

SELECT IDuser,
count(User-App.IDApp) as x
FROM User-App
INNER JOIN [App Profile]
ON User-App.IDApp = [App Profile].IDApp
HAVING count(User-App.IDApp) = dCount("IdApp", "[App Profile]")
GROUP BY IDUser;

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 25 '06 #4
"john" <jo**@test.comw rote in
news:3v******** *************** *******@casema. nl:
I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With fitting the
profile I mean that the user uses 1 to every App (but not more) of
those that are in the Profile table. In this case only user 1 and 3
fit the profile.

Can someone point me in the right direction?
Thanks!
john
Maybe ...

SELECT sq1.IDUser FROM
[SELECT UserApp.IDUser, COUNT(UserApp.I DUser) AS Count1
FROM UserApp LEFT JOIN AppProfile ON UserApp.IDApp = AppProfile.IDAp p
GROUP BY UserApp.IDUser
ORDER BY UserApp.IDUser]. sq1
INNER JOIN
[SELECT UserApp.IDUser, COUNT(UserApp.I DUser) AS Count2
FROM UserApp LEFT JOIN AppProfile ON UserApp.IDApp = AppProfile.IDAp p
WHERE AppProfile.IDAp p IS NOT NULL
GROUP BY UserApp.IDUser
ORDER BY UserApp.IDUser]. sq2
ON
sq1.IDUser=sq2. IDUser
AND
sq1.Count1=sq2. Count2

--
Lyle Fairfield

from http://msdn.microsoft.com/library/de...l=/library/en-
us/dnmdac/html/data_mdacroadma p.asp

Obsolete Data Access Technologies
Obsolete technologies are technologies that have not been enhanced or
updated in several product releases and that will be excluded from future
product releases. Do not use these technologies when you write new
applications. When you modify existing applications that are written
using these technologies, consider migrating those applications to
ADO.NET.
The following components are considered obsolete:
....
Data Access Objects (DAO): DAO provides access to JET (Access) databases.
This API can be used from Microsoft Visual Basic®, Microsoft Visual C++®,
and scripting languages. It was included with Microsoft Office 2000 and
Office XP. DAO 3.6 is the final version of this technology. It will not
be available on the 64-bit Windows operating system.
.....
Nov 25 '06 #5
"Lyle Fairfield" <ly***********@ aim.comschreef in bericht
news:Xn******** *************** **********@216. 221.81.119...
"john" <jo**@test.comw rote in
news:3v******** *************** *******@casema. nl:
>I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With fitting the
profile I mean that the user uses 1 to every App (but not more) of
those that are in the Profile table. In this case only user 1 and 3
fit the profile.

Can someone point me in the right direction?
Thanks!
john

Maybe ...

SELECT sq1.IDUser FROM
[SELECT UserApp.IDUser, COUNT(UserApp.I DUser) AS Count1
FROM UserApp LEFT JOIN AppProfile ON UserApp.IDApp = AppProfile.IDAp p
GROUP BY UserApp.IDUser
ORDER BY UserApp.IDUser]. sq1
INNER JOIN
[SELECT UserApp.IDUser, COUNT(UserApp.I DUser) AS Count2
FROM UserApp LEFT JOIN AppProfile ON UserApp.IDApp = AppProfile.IDAp p
WHERE AppProfile.IDAp p IS NOT NULL
GROUP BY UserApp.IDUser
ORDER BY UserApp.IDUser]. sq2
ON
sq1.IDUser=sq2. IDUser
AND
sq1.Count1=sq2. Count2
Lyle, this is amazing! It works! Thanks a lot!
Am I right that one can never build this query with the standarad access
query builder? Because when I view this query in the query builder I don't
even see the source table names.
john
Nov 25 '06 #6
"john" <jo**@test.comw rote in
news:a5******** *************** *******@casema. nl:
Thanks Bob,
Unfortunately I keep getting an error on:
>HAVING count(User-App.IDApp) = dCount("IdApp", "[App
Profile]")
I tried every possible quoting and also tried replacing , in ;
but I keep getting a syntax error.
Any idea what's causing this?
john
no, but remove it from the SQL view. Go to desing view.
add the field User-App.IDApp to the grid. put
dCount("IdApp", "[App Profile]") as criteria for the field.
change the Group By to WHERE.

try it again.

Bob

>
"Bob Quintal" <rq******@sPAmp atico.caschreef in bericht
news:Xn******** **************@ 66.150.105.47.. .
>"john" <jo**@test.comw rote in
news:3v******* *************** ********@casema .nl:
>>I have table User-App and table App Profile
User-App App Profile
IDuser IDApp IDApp
1 34 34
1 45 45
2 34
2 45
2 90
3 34

I can't seem to figure out the following:
I need to find out which user fits the App profile. With
fitting the profile I mean that the user uses 1 to every App
(but not more) of those that are in the Profile table. In
this case only user 1 and 3 fit the profile.

Can someone point me in the right direction?
Thanks!
john
paste this into the sql view of the query builder, it should
work.

SELECT IDuser,
count(User-App.IDApp) as x
FROM User-App
INNER JOIN [App Profile]
ON User-App.IDApp = [App Profile].IDApp
HAVING count(User-App.IDApp) = dCount("IdApp", "[App
Profile]") GROUP BY IDUser;

--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com



--
Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

Nov 25 '06 #7
"Bob Quintal" <rq******@sPAmp atico.caschreef in bericht
news:Xn******** **************@ 66.150.105.47.. .
"john" <jo**@test.comw rote in
news:a5******** *************** *******@casema. nl:
>Thanks Bob,
Unfortunatel y I keep getting an error on:
>>HAVING count(User-App.IDApp) = dCount("IdApp", "[App
Profile]")
I tried every possible quoting and also tried replacing , in ;
but I keep getting a syntax error.
Any idea what's causing this?
john

no, but remove it from the SQL view. Go to desing view.
add the field User-App.IDApp to the grid. put
dCount("IdApp", "[App Profile]") as criteria for the field.
change the Group By to WHERE.

try it again.
Thanks Bob,
Just did so. At first there was a syntax error again but when I changed the
, to ; the query ran. However with no resulting records. I will look into
this later as I have a deadline to catch.
john
Nov 25 '06 #8
john wrote:
Am I right that one can never build this query with the standarad access
query builder? Because when I view this query in the query builder I don't
even see the source table names.
There is an SQL view in the query builder (view pull-down - upper
left). That is where I constructed the query. Design view is limited in
that it does not seem to show or allow sub-queries as SQL strings, nor
non-equi joins. This can lead users to think that JET SQL is much less
powerful than it actually is.

On the other hand JET SQL has syntax rules for parentheses around JOINS
that I have not mastered, nor am I likely to as I now use SQL-Server
and the parentheses are not needed there. So when I am composing JOINS
in JET, I often fire up the query builder, do the JOINS with Table
Names and then switch to SQL view and modify the SQL to replace the
Table Names with subquery strings.
And the query builder is a great place to test things.

The query I posted seems very long and complicated to me. I hope
someone will post something simpler.

Nov 25 '06 #9
"Lyle Fairfield" <ly***********@ aim.comschreef in bericht
news:11******** **************@ f16g2000cwb.goo glegroups.com.. .
john wrote:
>Am I right that one can never build this query with the standarad access
query builder? Because when I view this query in the query builder I
don't
even see the source table names.

There is an SQL view in the query builder (view pull-down - upper
left). That is where I constructed the query. Design view is limited in
that it does not seem to show or allow sub-queries as SQL strings, nor
non-equi joins. This can lead users to think that JET SQL is much less
powerful than it actually is.

On the other hand JET SQL has syntax rules for parentheses around JOINS
that I have not mastered, nor am I likely to as I now use SQL-Server
and the parentheses are not needed there. So when I am composing JOINS
in JET, I often fire up the query builder, do the JOINS with Table
Names and then switch to SQL view and modify the SQL to replace the
Table Names with subquery strings.
And the query builder is a great place to test things.
Thank for explanation.
The query I posted seems very long and complicated to me. I hope
someone will post something simpler.
Anyway, the query saved me tons of work today...
john
Nov 26 '06 #10

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

Similar topics

9
3409
by: majsen | last post by:
Hi, I have problem running this query. It will time out for me... My database are small just about 200 members. I have a site for swaping appartments (rental). my query should look for match in a triangle. Like this member A -> B->C A give his appartment to B. B gives his appartment to C and finally C gives his appartment to A Soo my query looks for matching parameters like rooms, location, size
8
3274
by: Együd Csaba | last post by:
Hi All, how can I improve the query performance in the following situation: I have a big (4.5+ million rows) table. One query takes approx. 9 sec to finish resulting ~10000 rows. But if I run simultaneously 4 similar queries it takes nearly 5 minutes instead of 4 times 9 seconds or something near of that. here is a sample query: select mertido, fomeazon, ertektipus, mertertek from t_me30 where fomeazon in (select distinct fomeazon...
3
14133
by: John Ortt | last post by:
> I have a table of dates in ascending order but with varying intervals. I > would like to create a query to pull out the date (in field 1) and then pull > the date from the subsequent record (and store it in field 2). > > I would like to run a query that returns all the data in the table plus the > record number, in a similar sense to the getuser() command to get the User's > Identity, I would like a GetRecord() command.
3
3096
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table before rowID answID qryrow questionID datafield 1591 12 06e 06e 06e question 1593 12 06f 06f 06f question 1594 12 answer to the question 06f
7
3394
by: serge | last post by:
How can I run a single SP by asking multiple sales question either by using the logical operator AND for all the questions; or using the logical operator OR for all the questions. So it's always either AND or OR but never mixed together. We can use Northwind database for my question, it is very similar to the structure of the problem on the database I am working on. IF(SELECT OBJECT_ID('REPORT')) IS NOT NULL DROP TABLE REPORT_SELECTION
6
4853
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID SalesManName AT Alan Time
2
2045
by: mmitchell_houston | last post by:
I'm working on a .NET project and I need a single query to return a result set from three related tables in Access 2003, and I'm having trouble getting the results I want. The details: Question ------------ QuestionID QuestionText Question_MediaTypeID
22
31214
by: Stan | last post by:
I am working with Access 2003 on a computer running XP. I am new at using Access. I have a Db with a date field stored as mm/dd/yyyy. I need a Query that will prompt for the month, ie. 6 for June, and will return all records in that month.
3
2067
by: Richard Hollenbeck | last post by:
I am very sorry about the (almost) re-post, but you will see that my first question wasn't very clear; I have another question I posted this morning called, "in DAO: Run time error 3061 Too few parameters...." I have read many articles on the web about how to make a dynamic report based on a cross-tab query. But for some reason mine never works right. First, my saved query's criteria is the data in an open form's combo box. So the...
16
3527
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for renaming the duplicate records? My thinking was to take the results of the duplicate query, and somehow have it number each line where there is a duplicate (tried a groups query, but "count" won't work), then do an update query to change the duplicate to...
0
9605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10392
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...
0
10136
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...
0
9208
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
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
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4341
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
3868
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3020
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.