Hi. Any help will be much appreciated.
I have a a table with the following fields (actual tabale is much larger but for example sake I shortened it):
offender_id
program_id
counselor_id
case_no
attended
missed
total_attended
total_missed
When the Program link is clicked the table needs to display the last row inserted for each offender_id.
I am not able to figure out how to write the sql statement. I'm pretty new to SQL and just now figured out how to link tables.
Here is a copy of the actual statement that I need to write the statement for.
$sql = "SELECT schedule.oid, offender.f_name, offender.l_name, offender.ssn, schedule.case_no, schedule.attended, schedule.total_attended, schedule.missed, schedule.total_missed, schedule.module_completed, schedule.total_module_completed,schedule.pid, schedule.cid, schedule.poid, schedule.county_id, schedule.completed, schedule.date, schedule.day, schedule.time, program.program_name, program.day, program.time ".
"FROM offender, schedule, program, counselor ".
"WHERE offender.id = schedule.oid AND program.id = schedule.pid AND counselor.id = schedule.cid and schedule.pid = '$pid' ";
I have a a table with the following fields (actual tabale is much larger but for example sake I shortened it):
offender_id
program_id
counselor_id
case_no
attended
missed
total_attended
total_missed
When the Program link is clicked the table needs to display the last row inserted for each offender_id.
I am not able to figure out how to write the sql statement. I'm pretty new to SQL and just now figured out how to link tables.
Here is a copy of the actual statement that I need to write the statement for.
$sql = "SELECT schedule.oid, offender.f_name, offender.l_name, offender.ssn, schedule.case_no, schedule.attended, schedule.total_attended, schedule.missed, schedule.total_missed, schedule.module_completed, schedule.total_module_completed,schedule.pid, schedule.cid, schedule.poid, schedule.county_id, schedule.completed, schedule.date, schedule.day, schedule.time, program.program_name, program.day, program.time ".
"FROM offender, schedule, program, counselor ".
"WHERE offender.id = schedule.oid AND program.id = schedule.pid AND counselor.id = schedule.cid and schedule.pid = '$pid' ";