
- 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 a specific value between two column values in MySQL?
Let us first create a table −
mysql> create table DemoTable787 ( Score1 int, Score2 int, Name varchar(100) ); Query OK, 0 rows affected (0.84 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable787 values(34,56,'Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable787 values(73,86,'Robert'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable787 values(90,99,'David'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable787 values(80,89,'Adam'); Query OK, 1 row affected (0.21 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable787;
This will produce the following output -
+--------+--------+--------+ | Score1 | Score2 | Name | +--------+--------+--------+ | 34 | 56 | Chris | | 73 | 86 | Robert | | 90 | 99 | David | | 80 | 89 | Adam | +--------+--------+--------+ 4 rows in set (0.00 sec)
Following is the query to select a specific value between values of two columns −
mysql> select Name from DemoTable787 where 56 between Score1 and Score2;
This will produce the following output -
+-------+ | Name | +-------+ | Chris | +-------+ 1 row in set (0.00 sec)
- Related Articles
- Place a specific value for NULL values in a MySQL column
- Select minimum row value from a column with corresponding duplicate column values in MySQL
- Set a specific value for the first three column values in MySQL?
- Swap a specific column value in MySQL
- Get a random value between two values in MySQL?
- Fetch a specific column value (name) in MySQL
- MySQL query to select the nth highest value in a column by skipping values
- MySQL randomly select 2 values from column values?
- Show column value twice in MySQL Select?
- MySQL query to select column where value = one or value = two, value = three, etc?
- Replace only a specific value from a column in MySQL
- MySQL SELECT to sum a column value with previous value
- How to get a specific column record from SELECT query in MySQL?
- Fix a specific column value and display random values for rest of the rows in MySQL
- Swapping two column values in MySQL?

Advertisements