Using Select & Where clause for mySQL
Posted on 2006-06-02
I don't know whats wrong with my code, why my query returns empty always (No record found). I checked my table and it has records, but when ever i run the code below it will return empty.
I suspect that there is something wrong with the "Where.." part. My table has the valid dates inside so i don't believe these will not be seen whenever the query will be executed.
l_Query := TQuery.Create(fAppointmentScheduling);
l_Query.Active := False;
l_Query.DatabaseName := fMain.pSQLAlias;
l_Query.SQL.Add('Select APNTDATE from '+const_Appointments);
fromdate := datetostr(MonthCalendar1.date-5);//+' 00:00:01';
todate := datetostr(MonthCalendar1.date+5);//+' 23:59:59';
l_Query.SQL.Add('where ((DATE(APNTDATE) >= DATE('+fromdate+')) OR (DATE(APNTDATE) <= DATE('+todate+')))');
DataSource1.DataSet := l_Query;