473,669 Members | 2,421 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.las t_name

from section_master left outer join hdx_reg_class_p eriods on
section_master. udef_3a_1 = hdx_reg_class_p eriods.period
inner join section_schedul es on (section_master .crs_cde =
section_schedul es.crs_cde
and section_master. yr_cde = section_schedul es.yr_cde and
section_master. trm_cde = section_schedul es.trm_cde)
left outer join name_master on section_schedul es.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_p eriod_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 1167
schoultzy (sc*******@yaho o.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.las t_name
from section_master left outer join hdx_reg_class_p eriods on
section_master. udef_3a_1 = hdx_reg_class_p eriods.period
inner join section_schedul es on (section_master .crs_cde =
section_schedul es.crs_cde
and section_master. yr_cde = section_schedul es.yr_cde and
section_master. trm_cde = section_schedul es.trm_cde)
left outer join name_master on section_schedul es.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_p eriod_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****@sommarsk og.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*******@yaho o.com> wrote in message
news:11******** **************@ r2g2000cwb.goog legroups.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.las t_name

from section_master left outer join hdx_reg_class_p eriods on
section_master. udef_3a_1 = hdx_reg_class_p eriods.period
inner join section_schedul es on (section_master .crs_cde =
section_schedul es.crs_cde
and section_master. yr_cde = section_schedul es.yr_cde and
section_master. trm_cde = section_schedul es.trm_cde)
left outer join name_master on section_schedul es.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_p eriod_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.lg a...
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
3831
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' FOR Update; (when i execute this statement and i guess that this will lock the
2
6376
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. when a user tries to insert a record into one of the tables it
1
4476
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 DDPROD.pr_prodnum = DOBOM2.b2_prodnum INNER JOIN DDORD ON DOBOM2.b2_orid = DDORD.or_id INNER JOIN DDTORD ON DDORD.OR_TOID = DDTORD.TO_ID WHERE DOBOM2.b2_ordnum = ''order number here from result of outer select) AS Total" _ & "FROM DDTORD WHERE to_trak2id IN...
3
5723
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 pointing to the sentence they come from (a column called "regret"). I also have a table of stop words (called "GenericStopWords") that contains the words I do not want to consider. That table has a single column called "word". I started off using a...
7
11904
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 ] = "US"; is the SQL column name (because it sarts with 2?). As the statement is shown I get the error message: Unclosed quotation mark before the character
2
1578
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 @theTest1='TRUE'
12
7688
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 million rows and if I do a select * then I do get 1 million rows. I want to be able to provide page navigation as google does, page
3
6450
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 COULD be wrong... :) I've tried the access group...twice...and all I get is "Access doesn't like ".", which I know, or that my query names are too long, as there's a limit to the length of the SQL statement(s). But this works when I don't try to...
5
6892
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 the described properties. If I use the same statement in a select into statement (see the second select) I get several datasets with the described properties like I didn't use distinct
2
3405
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 well as a value for the exit status of the SP. If the record doesn't exist, it selects an error message as the exit status. I've recreated the SP (while changing field names) and restructured the table, just to get straight to the point.
0
8465
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
8895
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
8809
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...
1
8588
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
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
5682
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
4206
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...
1
2797
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
2032
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.