You are on page 1of 1

Prithvi M G,

Shilpashree N,
Shilpa H B

<? php
$mysql = mysql_connect (localhost,root)
or die (cannot connect database);
$inner = mysql_db_query (company ,select distinct salary from employee
order by salary desc);
$result = mysql_fetch_array ($inner);
$outer = mysql_db_query (company , select ename from employee where
salary = ($result[2]));
$result2 = mysql_fetch_array($outer);
for(i=0;i<mysql_num_rows($outer); i++)
{
echo $result2 [i];
}
?>
By assuming Company as a database and Employee as a table name which has salary and
ename as attributes,
1)Sort the distinct salaries of employees in descending order store it in an array.
2)retrieve the names using 2 as an index of an array
Using this we can get the list of employee name who are all getting third highest salary,
As well as we can retrieve the nth highest salary owned employee names ,just by changing
the index value.

You might also like