473,800 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Another query problem - what function?

For example, a database with three tables:
EMPLOYEE(employ ee#, empName, empAddress, empTel)
EMPLOYEE_ON_PRO JECT(employee#, project#)
PROJECT(project #, projectStartDat e, projectEndDate)

What sort of query would i have to run (or SQL would I have to type) to
return something like "A list of employee names for all of the employees
that are assigned to more than 2 projects (In the EMPLOYEE_ON_PRO JECT)"?
I've been toying with 'COUNT' but don't think that's the right one...

I'm just using this database as an example, at the least I would just like
to know what function I would have to use to get the results that I need.
Im pretty stumped!

Thanks, Fred
Nov 13 '05 #1
2 1359
sounds like right out of Elmasri's textbook! Wow.

Why not use the query builder?

Off the top of my head....

SELECT Employee.empNam e, Count(WorksOn.P rojectNo)
FROM Employee INNER JOIN WorksOn ON Employee.EmpNo= WorksOn.EmpNo
GROUP BY Employee.Employ eeNo
HAVING COUNT(WorksOn.P rojectNo)>1;

Nov 13 '05 #2
The example was something i'd done at uni, designing the database but not
doing any queries. It was the first thing that came to mind!

It works perfect for what i'm trying to do, so a really big thank you!

<pi********@hot mail.com> wrote in message
news:11******** *************@o 13g2000cwo.goog legroups.com...
sounds like right out of Elmasri's textbook! Wow.

Why not use the query builder?

Off the top of my head....

SELECT Employee.empNam e, Count(WorksOn.P rojectNo)
FROM Employee INNER JOIN WorksOn ON Employee.EmpNo= WorksOn.EmpNo
GROUP BY Employee.Employ eeNo
HAVING COUNT(WorksOn.P rojectNo)>1;

Nov 13 '05 #3

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

Similar topics

0
1841
by: Phil Powell | last post by:
I have a very simple mySqlQuery object that takes two parameters: 1) the string query 2) the db connection resource I tested and was certain everything is passing correctly (the string query and the db connection resource). The first mySqlQuery object produces just fine; but when I run it, the second mySqlQuery object (a totally different SQL query, same db connection resource) comes back null every time, even when there is data...
2
1438
by: Börni | last post by:
Hi, me again ;-) So i have this code: <?php $db = new db(); $sql = "SELECT id FROM contentobject_attribute WHERE contentobject_id=2 AND contentclassattribute_id=1"; $result = $db->query($sql); while ($row = $result->fetch_assoc()) { $result2 = $db->query("SELECT * FROM contentclass");
2
12400
by: Wilder | last post by:
I'm trying to update a field in one table with the minimum values of the field in another table. The two tables are linked via a common field. I want to populate a date field in one table with the earliest date in another table where the linking fields values are equal. I set up a query with the two tables, made sure the common fields were linked, set the query as an "update" query, placed the field and table I want to update in the...
2
14940
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data in the format that I need it in order to create the reports that we use. So far this has proven to be successful for the reports that I am doing and the data that I am pulling into it. I just have one challenge that may require a lot of work and I...
2
2310
by: Wayne Aprato | last post by:
I posted this yesterday and it seems like a moderator has thrown it in another thread. This is a totally different question to the one asked in that thread, so I'm posting it again. It is not a simple "numbering records on a report" question. It is more complex than that. I have a report that shows the results of a query. One of the fields is an autonumber field from the query which shows for instance: 120, 121 , 122 for 3 records. ...
1
3553
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary key) ss#
1
2019
by: hmiller | last post by:
I'm sorry to populate the server with yet another question about linking multiple tables and queries, howerver I have not been able to find the right criteria. My problem. I am trying to either link 3 tables together in a select query, and maintain the editablity that I get when linking two tables and creating a form. I know there is a way to link 3 tables through multiple queries however I have yet to be able to get it to work.
9
3138
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to be inserted into a standard web address in the table (the filed name is link) in ddw1 Example address ---
2
1784
by: iheartvba | last post by:
Hi, I usually use access query builder to create complex queries. Especially to create Sub Queries I.E. a querying another query. In my current situation I need to provide the criteria to the query from a Form and then call it using the rst function in ADO (see last line of my code). The issue with the rst function is that it doesn't cater for queries made in access query builder that have an object from a Form as their criteria. I have...
1
2232
by: chaurous | last post by:
hi guys, i have a problem of building a function and from the result i should append the results to another table. function required: my first idea is query but it is not working. how should i create this function? query or VBA? TableB.TestName = FormA.P1.Value; result of this is multiple records will be selected. From this result, how should i append the result of the query into another TableC?
0
9691
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
9551
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
10505
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
10276
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
10035
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
9090
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...
0
6813
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();...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.