Here you will find more than 50000 job interview questions

Job Questions Search Engine


Sponsored Links

How to find highest and second highest record or column value in sql

MySQL: In mysql to get the highest and second highest column or record we can use order by and limit

For example : The below query will give me the highest record:

SELECT * FROM `student` where class=’tenth’ ORDER BY mark desc LIMIT 0,1

To get the second highest record:

SELECT * FROM `student` where class=’tenth’ ORDER BY mark desc LIMIT 0,1

To get highest record or second highest record in Oracle we can use ROWNUM . Oracle doesn’t have LIMIT and ROWNUM works in the same way as LIMIT works in MYSQL.

Below query will give me the highest or the max student record with highest marks
SELECT * FROM `student` where class=’tenth’ and ROWNUM == 1 ORDER BY marks

Second highest record can be get through below command
SELECT * FROM `student` where class=’tenth’ and ROWNUM == 2 ORDER BY marks

Tedious way would be to write nested sql query to find the second highest record

SELECT score,player FROM scores WHERE score=(SELECT max(score) FROM scores WHERE score< (SELECT max(score) FROM scores));
The above finds the second highest score in the scores table and the name of the player.
Reading from right to left:
1. The first select finds the highest score.
2. The second select find the highest from the rest.
3. The last select finds the name of the player.

How do you change a password for an existing user via mysqladmin?

September 5, 2010 by bigboss · Leave a Comment
Filed under: MySQL Interview Questions 

mysqladmin -u root -p password “newpassword”.

How does mysql and mysqli interfaces are different in PHP?

mysqli is the object-oriented version of mysql library functions.
So in object oriented PHP Programming mysqli is normally prefered

How do you start and stop MySQL service

September 5, 2010 by bigboss · Leave a Comment
Filed under: MySQL Interview Questions 

Below are the command to start mysql database service on Windows
net start MySQL,
net stop MySQL

Below are the command to start mysql database service on Linux

/etc/init.d/mysql start

/etc/init.d/mysql stop

  • Categories

    |
  • Tags

    ADO.NET Questions Algorithm Questions ASP.NET Questions auto_ptr Binary tree questions C++ Constructor Interview Questions C++ Questions CISCO Exams Questions Common Interview Questions Core Java Interview Questions Csharp Questions datastructure questions Delphi 6 find command gdb interview questions grep interview questions IBM certification exams questions Infosys Puzzles Java Struts Linked List Problem Linux Command Questions List Manager Interview Questions Markov Algorithm memory leakage mysql Interview Questions Normalization Oracle Application Developer Certification Exam Interview Questions Oracle Questions Perl Questions PHP Questions Pointers Interview Questions PostgreSQL Database Questions pthread interview questions Smart Pointer Solaris Interview Questions SQL SERVER Interview Questions STL STL Map Symbian OS Tricky Interview Questions Unix Interview Questions unix shell Vector Windows OS Questions