

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 Questions & Answers
- 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?
- MySQL query to select one specific row and another random row?
- How to get a specific column record from SELECT query in MySQL?
- Delete all rows except only a specific row in MySQL?
- How to get multiple rows in a single MySQL query?
- MySQL query to get the highest value from a single row with multiple columns
- How to exclude a specific row from a table in MySQL?
- MySQL query to select rows except first row in descending order?
- MySQL query to select records beginning from a specific id
- Return only a single row from duplicate rows with MySQL
- MySQL query to get all characters before a specific character hyphen
- MySQL query to delete row
- Comparing two columns in a single MySQL query to get one row?
Advertisements