473,387 Members | 1,904 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.

Another query problem - what function?

For example, a database with three tables:
EMPLOYEE(employee#, empName, empAddress, empTel)
EMPLOYEE_ON_PROJECT(employee#, project#)
PROJECT(project#, projectStartDate, 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_PROJECT)"?
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 1343
sounds like right out of Elmasri's textbook! Wow.

Why not use the query builder?

Off the top of my head....

SELECT Employee.empName, Count(WorksOn.ProjectNo)
FROM Employee INNER JOIN WorksOn ON Employee.EmpNo=WorksOn.EmpNo
GROUP BY Employee.EmployeeNo
HAVING COUNT(WorksOn.ProjectNo)>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********@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
sounds like right out of Elmasri's textbook! Wow.

Why not use the query builder?

Off the top of my head....

SELECT Employee.empName, Count(WorksOn.ProjectNo)
FROM Employee INNER JOIN WorksOn ON Employee.EmpNo=WorksOn.EmpNo
GROUP BY Employee.EmployeeNo
HAVING COUNT(WorksOn.ProjectNo)>1;

Nov 13 '05 #3

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

Similar topics

0
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...
2
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 =...
2
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...
2
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...
2
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...
1
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...
1
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...
9
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...
2
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...
1
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...
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
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?
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
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,...

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.