How to select record except the lower value record against a specific value in MySQL?

MySQLMySQLi Database

For this, you need to use the WHERE clause. Following is the syntax −

select *from yourTableName where yourColumnName > yourValue;

Let us create a table −

mysql> create table demo27
−> (
−> id int not null auto_increment primary key,
−> value int
−> );
Query OK, 0 rows affected (3.14 sec)

Insert some records into the table with the help of insert command −

mysql> insert into demo27(value) values(50);
Query OK, 1 row affected (0.12 sec)

mysql> insert into demo27(value) values(500);
Query OK, 1 row affected (0.20 sec)

mysql> insert into demo27(value) values(100);
Query OK, 1 row affected (0.17 sec)

mysql> insert into demo27(value) values(400);
Query OK, 1 row affected (0.14 sec)

mysql> insert into demo27(value) values(100);
Query OK, 1 row affected (0.11 sec)

mysql> insert into demo27(value) values(800);
Query OK, 1 row affected (0.10 sec)

mysql> insert into demo27(value) values(600);
Query OK, 1 row affected (0.15 sec)

Display records from the table using select statement −

mysql> select *from demo27;

This will produce the following output −

+----+-------+
| id | value |
+----+-------+
|  1 | 50    |
|  2 | 500   |
|  3 | 100   |
|  4 | 400   |
|  5 | 100   |
|  6 | 800   |
|  7 | 600   |
+----+-------+
7 rows in set (0.00 sec)

Following is the query to select record except the lower value record against a value in MySQL −

mysql> select *from demo27 where value > 500;

This will produce the following output −

+----+-------+
| id | value |
+----+-------+
|  6 |   800 |
|  7 |   600 |
+----+-------+
2 rows in set (0.00 sec)
raja
Published on 19-Nov-2020 12:19:10
Advertisements