SiteExperts.com Logo Home | Community | Developer's Paradise
User Groups | Site Tools | Site Information | Search
 Main Menu
 Forums
SiteExperts.com Forums
All Discussions

SiteExperts Feedback
The Lounge
Dynamic HTML
Site Design/ Critiques
HTML and CSS
XML Technologies
The Wireless Internet
Internet Explorer
Microsoft .NET
The Server
Technical Support

Sponsored Links

User Groups : Forums : SiteExperts : The Server :

Previous DiscussionNext Discussion
 nested sql select

Hi,

I have a simple problem with select. The table teaching_courses
has information about semester, course name title etc.
For showing the current information :

select * from teaching_courses where teachyear=2006 And semester='winter_semester'

This works.I also have to make another html table that shows
all the past information. teaching_id is chronological and so i try :
SELECT * from teaching_courses
WHERE teaching_id < (select teaching_id from teaching_courses
where teachyear=2006 AND semester='winter_semester')

But this is not working. could you please help fixing this?.
thanks in advance.

Started By emsiva on Oct 24, 2006 at 12:05:56 PM

13 Response(s) | Reply

Earlier Replies | Replies 7 to 13 of 13 | Later Replies
Goto Page: 2 1
bod1467 on Oct 25, 2006 at 2:30:23 AM (# 7)

Like MHenke says, it would certainly make your database smaller (if you have lots of records). However, since you only have 2 semesters and your records are probably already complete in the database, then I would suggest leaving things alone. (Unless you're wanting to do this).


emsiva on Oct 25, 2006 at 3:59:42 AM (# 8)
This message has been edited.

That is a good idea. The mysql database has a teaching_courses
table with only 35 records at the moment. There are only 6 fields, so this is a small table. I try to insert data but its not working out...



insert into teaching_courses(semester,titleField,teachyear,documentFile,documentUrl)
values (
semester='winter_semester',
titleField='twttetw',
teachyear=1999,
documentFile='',
documentUrl='ffggfgfgfgfgdgd'
)

All i see is nulls in semester,titleField,teachyear and 1 in documentFile and 0 in documentUrl.

Teaching_courses is set on autoincrement,0 is the default value documentFile(varchar) and 0 in documentUrl(varchar) and the datatype of semester
is enum with two values winter_semester and summer_semester.
Could you please say what i have done wrong?


MHenke on Oct 25, 2006 at 4:31:47 AM (# 9)
This message has been edited.

Well, you're actually inserting a bunch of boolean values into your table.  8)

You've already named the columns you want to insert, don't do it again in the VALUES clause, it's plainly wrong syntax.


emsiva on Oct 25, 2006 at 6:18:40 AM (# 10)

Thanks for pointing that out , now its working :)


Jack Turk on Oct 25, 2006 at 6:10:12 PM (# 11)
This message has been edited.

>For showing the current information :

>select * from teaching_courses where teachyear=2006 And semester='winter_semester'

For showing all the past information (this assumes you have no future info in the DB):

SELECT * FROM teaching_courses WHERE NOT (teachyear=2006 AND semester='winter_semester')


Jaky123 on Sep 26, 2007 at 4:13:15 PM (# 12)
This message has been edited.

You are right.I agree witu you.

select * from teaching_courses where teachyear=2006 And semester='winter_semester'

For showing all the past information (this assumes you have no future info in the DB):

SELECT * FROM teaching_courses WHERE NOT (teachyear=2006 AND semester='winter_semester')

 

iphone accessories

ipod video converter


bod1467 on Sep 27, 2007 at 3:06:49 AM (# 13)

I see we have a new link spammer. :-D


Earlier Replies | Replies 7 to 13 of 13 | Later Replies
Goto Page: 2 1

To respond to a discussion, you must first logon.

If you are not registered, please register yourself to become a member of the SiteExperts.community.

User Name
Password
Copyright 1997-2004 InsideDHTML.com, LLC. All rights reserved.