I have two tables set up. One for student information, one for student/class listing. I'm coding in PHP using the sqlsrv plugin for MSSQL 2008 R2.
Student ID
Class Code
Student ID
First Name
Last Name
I need to select all students from a class but order by last name.
SELECT student_id FROM table1 WHERE class_code LIKE '402843'
$students = SELECT last_name, first_name FROM table2 WHERE student_id LIKE 'all results of first query'
Right now I can select all the students and display all the information; however, I can not sort them by last name. I'm sure this is possible, but seeing that the first query will return an array, I need the second query to return an array as well.
Any help would be greatly appreciated.