Author |
Topic |
es4725
Junior Member
205 Posts |
Posted - 15 March 2002 : 12:23:14
|
My SQL statement currently looks like this:
SELECT * FROM course WHERE Level <=9
I need to select a few columns (CourseID, CourseTitle, CourseSubTitle, Level, Credit, Coreq, and Prereq) and I need another option in the WHERE statement. I need it to be where Level <=9 (as it is) and also where Department = a string that will be varied dependant on a users click - say strDep for example. I don't remember right off the top of my head how it needs to be formatted, any help would be appreciated. Thanks
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 15 March 2002 : 12:29:27
|
quote:
My SQL statement currently looks like this:
SELECT * FROM course WHERE Level <=9
I need to select a few columns (CourseID, CourseTitle, CourseSubTitle, Level, Credit, Coreq, and Prereq) and I need another option in the WHERE statement. I need it to be where Level <=9 (as it is) and also where Department = a string that will be varied dependant on a users click - say strDep for example. I don't remember right off the top of my head how it needs to be formatted, any help would be appreciated. Thanks
Probably something like this:
strSql = "SELECT CourseID, CourseTitle, CourseSubTitle, Level, Credit, Coreq, Prereq FROM course WHERE (Level<=9) AND (Department=" & strDep & ");"
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
es4725
Junior Member
205 Posts |
Posted - 16 March 2002 : 01:58:12
|
Thanks Rui - I'll give that a go and let you know.
|
|
|
es4725
Junior Member
205 Posts |
Posted - 19 March 2002 : 12:00:19
|
I get this error:
The LEVEL clause includes a reserved word or argument that is misspelled or missing, or the punctuation is incorrect.
is LEVEL a reserved Word?
|
|
|
Kat
Advanced Member
United Kingdom
3065 Posts |
|
es4725
Junior Member
205 Posts |
Posted - 19 March 2002 : 12:18:31
|
that's odd - it hasn't given me any problems until now... alright - guess I'll have to change it though...
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 19 March 2002 : 13:27:51
|
If you want you can just use SELECT * FROM ..., instead of specifying all the fields you want. It will be a bit less efficient but won't force you to rename the field...
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
es4725
Junior Member
205 Posts |
Posted - 19 March 2002 : 21:02:16
|
I may do that for now... Thanks Rui... temporarily saved me some work...
|
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
|
es4725
Junior Member
205 Posts |
Posted - 20 March 2002 : 07:11:24
|
Now I'm getting another error Something along the lines of "No value given for required parameter" or something like that. I think the server just went down right after I hit refresh - so I can't really say for sure... when I find out I'll post here...Error is down below
This is what it looks like now by the way:
strSQLCourseFreshman = "SELECT * FROM course WHERE (Level<=9) AND (Department=" & strDep & ");"
*edit* Server's back up. Here's the error message:
No value given for one or more required parameters
*/edit*
Edited by - es4725 on 20 March 2002 07:14:23 |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 20 March 2002 : 07:33:00
|
Please post the value of the strSQLCourseFreshman variable. Just Response.Write its value so that we know the SQL string that is being sent to the database.
------------------------------------------------- Installation Guide | Do's and Dont's | MODs
Edited by - ruirib on 20 March 2002 07:36:39 |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 20 March 2002 : 08:13:45
|
Its still the same problem as above I suspect, you still have level in the query and it might be trying to parse that as something else,
try
strSQLCourseFreshman = "SELECT * FROM course WHERE ([Level]<=9) AND (Department=" & strDep & ");"
www.daoc-halo.com |
|
|
es4725
Junior Member
205 Posts |
Posted - 20 March 2002 : 08:15:28
|
Here it is:
SELECT * FROM course WHERE (Level<=9) AND (Department=Math);
|
|
|
es4725
Junior Member
205 Posts |
Posted - 20 March 2002 : 08:19:31
|
quote:
strSQLCourseFreshman = "SELECT * FROM course WHERE ([Level]<=9) AND (Department=" & strDep & ");"
No go either... I don't think it's a problem with Level. If I delete "AND (Department=" & strDep & ");", then the sql call functions, not with the desired results obviously, but it does call * FROM course WHERE (Level<=9) without a problem.
*edit* I'll be back on in about 3 1/2 hours at school, gotta get there now though. */edit*
Edited by - es4725 on 20 March 2002 08:21:34 |
|
|
ruirib
Snitz Forums Admin
Portugal
26364 Posts |
Posted - 20 March 2002 : 08:23:21
|
To Gremlin: I don't think it is due to Level in the WHERE. I tried using it in a DB of my own and I only got problems when using Level in the SELECT part.
I suppose Math is a string, right?
Change your code to this:
strSQLCourseFreshman = "SELECT * FROM course WHERE (Level<=9) AND (Department=""" & strDep & """);"
------------------------------------------------- Installation Guide | Do's and Dont's | MODs |
|
|
Gremlin
General Help Moderator
New Zealand
7528 Posts |
Posted - 20 March 2002 : 08:31:05
|
I haven't used access alot so I'm not 100% up with the correct syntax, quotes around 'math' maybe required ?
EDIT: Doh beaten to it
www.daoc-halo.com
Edited by - Gremlin on 20 March 2002 08:31:37 |
|
|
Topic |
|