$strSQL="SELECT * FROM TABLE1"
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mssql_fetch_array($objQuery))
{
$strSQL1="SELECT * FROM TABLE2 WHERE IDTABLE2='".$objResult["IDTABLE1"]."'"
$objQuery1 = mssql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
while($objResult1 = mssql_fetch_array($objQuery1))
}