473,508 Members | 4,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SELECT statement help

Hello everyone,

I am working with the following code:

select section_master.trm_cde, section_master.crs_cde, crs_title,
crs_capacity,
crs_enrollment, section_master.udef_3a_1, monday, tuesday, wednesday,
thursday, friday, begin_time, end_time, bldg_cde, room_cde,
name_master.last_name

from section_master left outer join hdx_reg_class_periods on
section_master.udef_3a_1 = hdx_reg_class_periods.period
inner join section_schedules on (section_master.crs_cde =
section_schedules.crs_cde
and section_master.yr_cde = section_schedules.yr_cde and
section_master.trm_cde = section_schedules.trm_cde)
left outer join name_master on section_schedules.professor_id_num =
name_master.id_num

where section_master.yr_cde = '2006'
order by section_master.trm_cde, bldg_cde, room_cde,
section_master.udef_3a_1

Some clarification, section_master.udef_3a_1 holds the class period in
which a given class occurs. This SELECT statement returns all classes
and rooms that are taken (currently being used). I would like to turn
this statement around to get all the classes and rooms that are not
taken (not currently being used). I also have to take into account
those course periods that conflict with other course periods. These
conflicts are listed in a table, hdx_reg_class_period_conflicts, which
contains to columns: one that lists the course period and one that
lists the conflict for that period (there can be multiple conflicts for
a given period). I am hoping that someone out there could help me
accomplish this as I am a novice when it comes to SQL.

Jun 26 '06 #1
3 1160
schoultzy (sc*******@yahoo.com) writes:
I am working with the following code:

select section_master.trm_cde, section_master.crs_cde, crs_title,
crs_capacity,
crs_enrollment, section_master.udef_3a_1, monday, tuesday, wednesday,
thursday, friday, begin_time, end_time, bldg_cde, room_cde,
name_master.last_name
from section_master left outer join hdx_reg_class_periods on
section_master.udef_3a_1 = hdx_reg_class_periods.period
inner join section_schedules on (section_master.crs_cde =
section_schedules.crs_cde
and section_master.yr_cde = section_schedules.yr_cde and
section_master.trm_cde = section_schedules.trm_cde)
left outer join name_master on section_schedules.professor_id_num =
name_master.id_num

where section_master.yr_cde = '2006'
order by section_master.trm_cde, bldg_cde, room_cde,
section_master.udef_3a_1

Some clarification, section_master.udef_3a_1 holds the class period in
which a given class occurs. This SELECT statement returns all classes
and rooms that are taken (currently being used). I would like to turn
this statement around to get all the classes and rooms that are not
taken (not currently being used). I also have to take into account
those course periods that conflict with other course periods. These
conflicts are listed in a table, hdx_reg_class_period_conflicts, which
contains to columns: one that lists the course period and one that
lists the conflict for that period (there can be multiple conflicts for
a given period). I am hoping that someone out there could help me
accomplish this as I am a novice when it comes to SQL.

And in which tables are the classes and rooms defined?

It is very difficult to work with tables that I don't know much about.
Not the least when the names are so cryptic as they are in this case.

I would suggest that you start with cleaning up the query, so that
you use aliases rather than the table names as prefix, and that you
then make sure that all columns are prefixed, so that we can see
from which tables they come from.

Even better, post CREATE TABLE statements for all tables (don't
forget the keys) with a short explanation of their purpose, and
INSERT statements with sample data, and the desired result given
the sample. Yes, I gather that this would be quite a lot of code
to post. Then again you need those INSERT statements anyway so that
you can test your final query.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jun 26 '06 #2
BTW I think the standard now is if you want to blast your email to 500
relevant newsgroups, you post to them all at once. That way if someone
answers your question it will show up in all the groups at once. So people
won't spend hours trying to resolve an issue that others have already
resolved. And post some DDL.

"schoultzy" <sc*******@yahoo.com> wrote in message
news:11**********************@r2g2000cwb.googlegro ups.com...
Hello everyone,

I am working with the following code:

select section_master.trm_cde, section_master.crs_cde, crs_title,
crs_capacity,
crs_enrollment, section_master.udef_3a_1, monday, tuesday, wednesday,
thursday, friday, begin_time, end_time, bldg_cde, room_cde,
name_master.last_name

from section_master left outer join hdx_reg_class_periods on
section_master.udef_3a_1 = hdx_reg_class_periods.period
inner join section_schedules on (section_master.crs_cde =
section_schedules.crs_cde
and section_master.yr_cde = section_schedules.yr_cde and
section_master.trm_cde = section_schedules.trm_cde)
left outer join name_master on section_schedules.professor_id_num =
name_master.id_num

where section_master.yr_cde = '2006'
order by section_master.trm_cde, bldg_cde, room_cde,
section_master.udef_3a_1

Some clarification, section_master.udef_3a_1 holds the class period in
which a given class occurs. This SELECT statement returns all classes
and rooms that are taken (currently being used). I would like to turn
this statement around to get all the classes and rooms that are not
taken (not currently being used). I also have to take into account
those course periods that conflict with other course periods. These
conflicts are listed in a table, hdx_reg_class_period_conflicts, which
contains to columns: one that lists the course period and one that
lists the conflict for that period (there can be multiple conflicts for
a given period). I am hoping that someone out there could help me
accomplish this as I am a novice when it comes to SQL.

Jun 28 '06 #3

"Mike C#" <xx*@yyy.com> wrote in message news:jo***************@fe12.lga...
BTW I think the standard now is if you want to blast your email to 500
relevant newsgroups, you post to them all at once.


Well if you blast it to 500 newsgroups, you'll probably get kicked off your
ISP. ;-)

But, yes generally cross-posting to 2-3 relevant newsgroups is preferred
over multi-posting to the same 2-3.

For the reason you give.
Jun 29 '06 #4

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

Similar topics

5
3820
by: jayson_13 | last post by:
Hi, I need to implement a counter and i face problem of locking so hope that u guys can help me. I try to do test like this : 1st connection SELECT * FROM nextkey WHERE tblname = 'PLCN'...
2
6356
by: Edwinah63 | last post by:
Hi Everyone, All the very best for 2004!! i need urgent help with this problem, the users are about to skin me alive!! we have an access front end with linked to sql server 2k tables. ...
1
4461
by: brett | last post by:
Here is my SQL string: "SELECT to_ordnum, to_orddate," _ & "(SELECT SUM((DDPROD.pr_stanmat * DDPROD.pr_prfact) * (DOBOM2.b2_quant * DDORD.or_quant)) FROM DDPROD INNER JOIN DOBOM2 ON...
3
5708
by: dumbledad | last post by:
Hi All, I'm confused by how to replace a SELECT statement in a SQL statement with a specific value. The table I'm working on is a list of words (a column called "word") with an index int...
7
11895
by: CharlesEF | last post by:
Hi All, I have run into another problem that is eating my lunch. Should be simple but I am having one heck of a time. Please look at this SELECT statement: SELECT FROM States WHERE ] =...
2
1571
by: GIS Analyst | last post by:
Hi to all I wish to be able to have a standard select statement which has additional fields added to it at run-time based on supplied parameter(s). ie declare @theTest1 nvarchar(10) set...
12
7659
by: TP | last post by:
Here is my problem. I need to display a table about which I have no information except the table name. Using metadata I can somehow show the column names and record values. But my table has 1...
3
6425
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
5
6887
by: Daniel Wetzler | last post by:
Dear MSSQL experts, I use MSSQL 2000 and encountered a strange problem wqhile I tried to use a select into statement . If I perform the command command below I get only one dataset which has...
2
3395
by: kxyz | last post by:
Hello everyone, I need help with a stored procedure or two. My stored procedures are supposed to check if a certain record exists. If it does exist, then I select everything from that row, as...
0
7228
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,...
1
7058
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...
0
7502
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...
1
5057
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...
0
3206
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...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1565
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 ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
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...

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.