Mysql query between 2 dates from multiple tables that has relation

Hi i have trouble with my query.

I have a gridview that counts all the students who have that particular ailment according to their section. And what i want is to filter between 2 dates since i have multiple tables.

    Dim query As String
query = "SELECT count(student_id) as i from students, patient, ailment 
         WHERE students.sid=patient.student_id AND 
         patient.ailment_id=ailment.ailment_id and section WHERE 
         patient.date_created BETWEEN @d1 AND @d2"

Dim data_table As New DataTable
sql_command = New MySqlCommand(query, myconnection.open())

sql_command.Parameters.Add("@d1", MySqlDbType.DateTime).Value = 
        dateStart.Value
sql_command.Parameters.Add("@d2", MySqlDbType.DateTime).Value = 
        dateEnd.Value

Dim adapter As New MySqlDataAdapter(sql_command)

adapter.Fill(data_table)
DataGridView1.DataSource = data_table

myconnection.close()

Datagrid link for datagrid sample

Error link to query error

#mysql #vb.net

1.55 GEEK