
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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)
Advertisements