PHP/MySql - INNER JOIN from another query
Posted on 2003-11-07
I would like to know how i could achieve a query with the result of another query.. here is my example:
$sql = "SELECT tblranking.IdMembre, Max(tblranking.myDate) AS MaxOfmydate FROM tblranking WHERE Type='DOUBLE' GROUP BY tblranking.IdMembre";
$result = SQL_Query($sql);
$sql2 = "SELECT tblranking.IdRanking, tblranking.IdMembre, tblranking.myDate, tblranking.Points FROM tblranking INNER JOIN $result ON (tblranking.IdMembre = $result["IdMembre"]) AND (tblranking.myDate = $result["MaxDemydate"]) ORDER BY Points DESC";
$result2 = SQL_Query($sql2);
my first query get the ranking up-to-date and the second get the points each member get and i sort it to get the one who has the more points.
The problem is that i don't know how to make the INNER JOIN $result ON ... i know result is an array, but is there a way to make it work?
Oh and if you happen to know how i can test it in PhpMyAdmin, it would be awesome!
It's gonna help me alot for future joins using MySql.
Thanks in advance.