Q:

Is there any way to make this code more efficient?..can't directly use IN coz version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery

Link that i referred to -> MySQL - This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery
I have a teacher that has a code and a mac address attached to the router.. the students have to enter the same code from the same mac address.. i want a list of students who have done it ... and i want to only check the last code uploaded by the teacher
thank you for all the help :)
My code(which is working)-> 
SELECT s.s_id
FROM students s
WHERE s.mac IN
    (SELECT *
     FROM
       (SELECT t.mac
        FROM teacher t
        ORDER BY t.sno DESC
        LIMIT 1)temp_tab)
  AND s.code IN
    (SELECT *
     FROM
       (SELECT t.code
        FROM teacher t
        ORDER BY t.sno DESC
        LIMIT 1)temp_tab);

A:

Using a join should be more efficient, but then again, it depends on what you are trying to achieve.
SELECT s.s_id
FROM students s
JOIN (
    SELECT t.mac, t.code
    FROM teacher t
    ORDER BY t.sno DESC
    LIMIT 1
) t ON s.mac = t.mac AND s.code = t.code

Indexing the matching or ordering columns would increase the performance too.

