I'm trying to make this query to look for the records whose id are from a certain customer, but it returns the first records of the table. I need to do this same query, but that returns the last records of the table, that is, the most current ones. Any idea how I can do this?
SELECT table1.sl,table1.idm
FROM table1
INNER JOIN table2 ON table1.idm=table2.idm
WHERE table2.idc=4
GROUP BY table1.idm
This query returns the first records of the table.
edit* I managed to accomplish what I need using the following query, however, it took 20 seconds to execute.
SELECT table1.sl, table1.idm FROM table1 INNER JOIN table2 ON table2.idm = table1.idm WHERE table2.idc=132 AND table1.id IN ( SELECT MAX(id) FROM table1 GROUP BY idm ) GROUP BY table1.idm