
- 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
MySQL query to get a specific row from rows
Let us first create a table −
mysql> create table DemoTable1972 ( Section char(1), StudentName varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1972 values('D','Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('B','David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('A','Mike'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1972 values('C','Carol'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1972;
This will produce the following output −
+---------+-------------+ | Section | StudentName | +---------+-------------+ | D | Chris | | B | David | | A | Mike | | C | Carol | +---------+-------------+ 4 rows in set (0.00 sec)
Here is the query to get a specific rows from rows −
mysql> select * from DemoTable1972 where Section > 'C' order by Section limit 2;
This will produce the following output −
+---------+-------------+ | Section | StudentName | +---------+-------------+ | D | Chris | +---------+-------------+ 1 row in set (0.00 sec)
- Related Articles
- Get only a single value from a specific MySQL row?
- How to find specific row with a MySQL query?
- MySQL query to count rows with a specific column?
- How to get a specific column record from SELECT query in MySQL?
- Delete all rows except only a specific row in MySQL?
- MySQL query to select one specific row and another random row?\n
- How to get multiple rows in a single MySQL query?
- MySQL query to select rows except first row in descending order?
- Get the first 10 rows followed by the syntax to display remaining row records with a single MySQL query
- How to exclude a specific row from a table in MySQL?
- MySQL query to get all characters before a specific character hyphen
- MySQL query to select records beginning from a specific id
- Comparing two columns in a single MySQL query to get one row?
- Return only a single row from duplicate rows with MySQL
- Get values from all rows and display it a single row separated by comma with MySQL

Advertisements