此代码用于查找员工的最高工资,使用 netbeans 中的 java 存储在 phpmyadmin 数据库中的数据:
case 5:{//start of max salary 5
RS = st.executeQuery("select * from firsttable where having max(salary)");
System.out.println("the employee with max salary: ");
while (RS.next())
{ //start while loop
//retrieve data
String []data = {RS.getString("ID"),
RS.getString("firstName"),
RS.getString("lastName"),
RS.getString("birthDate"),
RS.getString("salary"),
RS.getString("lastLogin")};
{//start print data
System.out.println("ID: "+data[0]);
//System.out.println("ID int: "+RS.getInt("ID"));
System.out.println("firstName: "+data[1]);
System.out.println("lastName: "+data[2]);
System.out.println("birthDate: "+data[3]);
System.out.println("salary: "+data[4]);
System.out.println("lastLogin: "+data[5]);
}//end print data
}//end while loop
break;
}//end of max salary 5