"between" query

bshaen

Member
Joined
Mar 10, 2005
Messages
19
i am confuse with "between" query in sql, now i have a form that will display the data retrieve from 3 tables.
std and std1 is a global string variable.

display = "SELECT s.*, e.* FROM Student s, Exam e, StdExam se WHERE "
display = display & "s.StdCode = " & std & " BETWEEN " & "s.StdCode = " & std1 & " AND "
display = display & "se.StdCode = s.StdCode AND se.ExamCode = e.ExamCode"
mySqlCommand = New SqlCommand(display, mySqlConnection)
myReader = mySqlCommand.ExecuteReader

can anyone help me to check what the mistake i made above?? its cant work purposely in my program. :mad:
 
Try this

bshaen said:
i am confuse with "between" query in sql, now i have a form that will display the data retrieve from 3 tables.
std and std1 is a global string variable.

display = "SELECT s.*, e.* FROM Student s, Exam e, StdExam se WHERE "
display = display & "s.StdCode = " & std & " BETWEEN " & "s.StdCode = " & std1 & " AND "
display = display & "se.StdCode = s.StdCode AND se.ExamCode = e.ExamCode"
mySqlCommand = New SqlCommand(display, mySqlConnection)
myReader = mySqlCommand.ExecuteReader

can anyone help me to check what the mistake i made above?? its cant work purposely in my program. :mad:


The proper format for your query is:

SELECT [list of fields] FROM
WHERE [Field] between std AND std1 ...
 
Back
Top