
- 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
How to find specific row with a MySQL query?
Let us first create a table −
mysql> create table DemoTable ( UserId int, UserName varchar(100) ); Query OK, 0 rows affected (0.66 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values(100,'Chris'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(101,'Bob'); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values(102,'David'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(103,'Mike'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(104,'Sam'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+--------+----------+ | UserId | UserName | +--------+----------+ | 100 | Chris | | 101 | Bob | | 102 | David | | 103 | Mike | | 104 | Sam | +--------+----------+ 5 rows in set (0.00 sec)
Following is the query to find the specific row and display the record of that row −
mysql> select *from DemoTable where UserId=102 and UserName='David';
This will produce the following output −
+--------+----------+ | UserId | UserName | +--------+----------+ | 102 | David | +--------+----------+ 1 row in set (0.00 sec)
- Related Articles
- MySQL query to get a specific row from rows
- MySQL query to select one specific row and another random row?\n
- MySQL query to insert row with date?
- MySQL query to count rows with a specific column?
- MySQL query to select a specific string with special characters
- MySQL query to delete row
- How to exclude a specific row from a table in MySQL?
- Query in MySQL for string fields with a specific length?
- MySQL query to count records that begin with specific letters
- MySQL insert a value to specific row and column
- How to find tables with a specific column name in MySQL?
- How to count number of specific symbols in a row in MySQL?
- MySQL query to return multiple row records with AND & OR operator
- MySQL SELECT query to return records with specific month and year
- MySQL query to split a column after specific characters?

Advertisements