Site icon TestingDocs.com

Retrieve Information from a MySQL Table

Overview

We can retrieve information from a MySQL database table using the SELECT statement. We will the table created in this example:

https://www.testingdocs.com/insert-data-into-a-mysql-database-table/

SELECT statement is used to retrieve information from the database table. The statement supports many clauses.

Select all rows

To retrieve all the rows in the table we use the following statement:

SELECT  * FROM <table_name>

For example, to retrieve all the rows in the table named supplier,

SELECT * FROM supplier;

SELECT * FROM testdb.supplier;

The * in the command will fetch all the columns in the table.

 

Select particular columns

We can specify the columns to show particular columns in the query output. For example, if we want only the supplier id column in the query result, we can use the following query.

SELECT supplier_id FROM supplier;

Select particular Rows

The WHERE clause if specified in the SELECT statement returns only the rows satisfied by the WHERE condition/(s).

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version