The whole issue is due to the fact that sub queries in a IN
clause doesn't seem to work on mysql 3.23.
Here's my table structure for table1:
|**idTable1**|**strDescription**|
|1 |blablabla |
|2 |blablabla |
Here's table2:
|**idTable2**|**idTable1**|**intVersion**|
|1 |1 |1 |
|2 |1 |8 |
|3 |2 |2 |
|4 |2 |3 |
What I'm looking to achieve:
Join both tables only to get the description but I only want 1 record of each row that has the biggest version like this:
|**idTable1**|**strDescription**|**idTable2**|**idTable1**|**intVersion**|
|1 |blablabla |2 |1 |8 |
|2 |blablabla |4 |2 |3 |
Here's what I came up with:
SELECT table1.idTable1, strDescription, intVersion FROM table1
INNER JOIN table2 ON table1.idTable1 = table2.idTable1
WHERE (table1.idTable1, intVersion)
IN (SELECT idTable1, MAX(intVersion) FROM table2 GROUP BY idTable1)
I've tested this query on 2 different versions of mysql. The one I need this to work on is 3.23 and the one where this query works is 5.5.
Is there a way to achieve this on 3.23?