SQL syntax in C#

timothy2l

Regular
Joined
Jul 3, 2003
Messages
61
Can someone tell me the correct syntax for the following SQL statement using C#?

SELECT COURSESNEEDED.CourseNumber, COURSESNEEDED.CourseName, COURSESNEEDED.CreditHours, REQUISITE.CourseName, REQUISITE.ReqType
FROM COURSESNEEDED, REQUISITE
WHERE COURSESNEEDED.CourseName = REQUISITE.CourseName
AND COURSESNEEDED.CourseNumber < 2000
AND REQUISITE.ReqType = 'Prerequisite'

Thanks in advance.
 
Sorry for the confusion. I wasn't sure if the syntax would be different when typing the SQL statement in the cs code. Ex. sqlString = "SELECT * FROM Table1";
I wasn't sure if there would be any extra characters, etc. when querying multiple tables and having contraints. I guess it makes sense that it wouldn't change.
 
The only thing that could force to change the query is if you have code that you want to make DB independent, meaning that you want your application to run on a DB user choose, so you would need different queries for different DBs if they need to be different. But it still has to be written in SQL syntax.
 
This is not about SQL syntax, but you need to escape the double quote character (") if you use a double quote in a SQL statement.
For example,

"SELECT \"last name\" FROM Person"
 
Back
Top