473,569 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL, Count and subqueries

Here is the situation:

I have one table that lists a number of courses available (including
CourseID, CourseName and MaxPositions), with CourseID being auto_increment
and unique

I have another table which has CourseRegistrat ion (Containing CourseID and
CustomerID), with no unique fields. Customer information is stored
elswhere.

Without having a field in the Courses table holding the number of people
currently registered, how would I return a result set which included:

CourseID, CourseName, MaxPositions and the Number of people registered to
take that course.

Preferably this would not use features in MySQL 4.1, but anything is fair
game at this point.

Thank you for all of your help.

Garrett Kajmowicz
gk******@tbayte l.net
Jul 19 '05 #1
0 2044

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

Similar topics

2
2726
by: JaNE | last post by:
Maybe this isn't the most apropriate place to ask mysql related question, but I think it is close enought to most php users and I always got find answers on this group. well, I need to count how meny rows have some maximum number. here is exact situation (striped down table) (pictID, jpeg name, #of votes) pict1, name1.jpg, 4 pict2,...
6
2050
by: Daniel Elliott | last post by:
Hello, I was wondering if anyone would be able to help me with a problem I'm having. I'm trying to use the following query: SELECT Distinct c.site_id FROM campsite c WHERE c.site_id NOT IN (SELECT cs.site_id FROM campsite_status cs WHERE c.site_id = cs.site_id
1
753
by: Garrett Kajmowicz | last post by:
Here is the situation: I have one table that lists a number of courses available (including CourseID, CourseName and MaxPositions), with CourseID being auto_increment and unique I have another table which has CourseRegistration (Containing CourseID and CustomerID), with no unique fields. Customer information is stored elswhere. ...
5
2418
by: Nick | last post by:
Im moving a development app (MySQL 5.0) to a different server which runs MySQL 4.0.20-standard. I am getting errors on queries that have subqueries such as... SELECT id FROM table1 WHERE id IN ( SELECT id FROM table1 )
4
5933
by: crane.jake | last post by:
Hi, I'm trying to find the following information from the table found bellow. Year_Sales - # of sales that have occurred this year Year_Income - SUM(amount) Month_Sales - # of sales that have occurred this month Month_Income - SUM(amount) Today_Sales -- # of sales that have occurred today Today_Icome - SUM(amount)
1
2592
by: Bill | last post by:
I'm trying to write a query that will select a distinct count of more than one field. I have records that display user productivity. Each of the records have a time associated with it and I want to be able to tell the distinct count of the products numbers and of the pallets ID that they worked with. Do need to work out some sort of sub-query...
2
12066
by: Pete | last post by:
I need to create a single query (Not a SQL query) against a single table that counts the number of records in the table, where the single field "tmp" contains specific string values If the field contains "AAA" the count is X. if the field contains "CCC" the count is Y. if the field contains "Stop" then count is Z. I have tried several...
4
2946
by: muzu1232004 | last post by:
Can anyone explain me when we use correlated subqueries rather than nested subqueries. Do all the correlated subqueries can be written in nested subqueries form as well ? What are the major conditions that apply whenever we write a correlated subquery and why we go for it ? Please let me know about this as i am not clear which to use when.
0
5694
debasisdas
by: debasisdas | last post by:
Using Subqueries ================== The sub query is often referred to as a nested SELECT, Sub - SELECT, or inner SELECT statement. The sub query executes once before the main query. The result of the sub query is used by the main query (outer Query). You can place the sub query in a number of SQL clauses. WHERE clause
1
2871
by: lizandra | last post by:
Greetings, I am a newbie, I have been working to extract data from a basic sales db and trying to decide when I should use joins and when I should use subqueries. Much of what I read online says use subqueries only as a last resort, especially correlated ones as they do a record by record data evaluation and are very resource intensive. Are...
0
7701
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...
0
7615
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...
1
7677
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...
0
7979
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...
1
5514
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...
0
5219
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...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
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
0
940
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...

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.