
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Select highest salary in MySQL?
For this, you can use MAX(). The syntax is as follows −
select MAX(yourColumnName) AS anyAliasName from yourTableName;
Let us create a table −
mysql> create table demo44 −> ( −> employee_id int not null auto_increment primary key, −> employee_name varchar(20), −> employee_salary int −> ) −> ; Query OK, 0 rows affected (1.27 sec)
Insert some records into the table with the help of insert command −
mysql> insert into demo44(employee_name,employee_salary) values('John',3000); Query OK, 1 row affected (0.13 sec) mysql> insert into demo44(employee_name,employee_salary) values('David',4500); Query OK, 1 row affected (0.12 sec) mysql> insert into demo44(employee_name,employee_salary) values('Bob',3500); Query OK, 1 row affected (0.12 sec) mysql> insert into demo44(employee_name,employee_salary) values('Carol',5500); Query OK, 1 row affected (0.15 sec) mysql> insert into demo44(employee_name,employee_salary) values('Mike',4900); Query OK, 1 row affected (0.13 sec)
Display records from the table using select statement −
mysql> select *from demo44;
This will produce the following output −
+-------------+---------------+-----------------+ | employee_id | employee_name | employee_salary | +-------------+---------------+-----------------+ | 1 | John | 3000 | | 2 | David | 4500 | | 3 | Bob | 3500 | | 4 | Carol | 5500 | | 5 | Mike | 4900 | +-------------+---------------+-----------------+ 5 rows in set (0.00 sec)
Following is the query to select highest salary −
mysql> select MAX(employee_salary) AS Highest_Salary from demo44;
This will produce the following output −
+----------------+ | Highest_Salary | +----------------+ | 5500 | +----------------+ 1 row in set (0.00 sec)
- Related Articles
- Select nth highest value in MySQL
- MySQL query to select maximum and minimum salary row?
- How can we fetch a second highest salary of an employee from a MySQL table?
- How can I select the row with the highest ID in MySQL?
- MySQL query to select the nth highest value in a column by skipping values
- MySQL edit and update records including employee salary
- MySQL query to select three highest values and sort alphabetically on the basis of corresponding column with name
- Only display row with highest ID in MySQL
- Return the field with highest count in MySQL
- MySQL Select IN range?
- Select into in MySQL?
- Display highest amount from corresponding duplicate ids in MySQL
- Get the difference between dates and calculate salary with MySQL?
- SELECT increment counter in MySQL?
- MYSQL - select database?

Advertisements