Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

  • *Experts*
Posted
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.
Posted

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"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...