0% found this document useful (0 votes)
25 views1 page

Prithvi M G, Shilpashree N, Shilpa H B

The document discusses retrieving employee names who earn the third highest salary from a database table. It connects to a database, queries for distinct salaries sorted descending, stores the result in an array, then queries for employee names with the third highest salary and outputs the results.

Uploaded by

sandeepbg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views1 page

Prithvi M G, Shilpashree N, Shilpa H B

The document discusses retrieving employee names who earn the third highest salary from a database table. It connects to a database, queries for distinct salaries sorted descending, stores the result in an array, then queries for employee names with the third highest salary and outputs the results.

Uploaded by

sandeepbg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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