MySQL Select Statement


MySQL Select Statement

MySQL Select statement  is used In Selecting one or more records in MySQL database, the SELECT statement is being used.


SELECT * from tableName;


SELECT column1,column2  from tableName;

The asterisks(*) symbol in our first example syntax represent all column in the database table.

In the second example, we specify the column name of a table.

Example using MySQLi (Object-Oriented):



Code explanation:

We just simply Select the Last name, First Name and Address of a person from our table, then we execute the query and store the results to the “$result” variable.

Next, using the num_rows function check if the result is greater than zero. And if the result is greater than zero, the fetch_assoc() function will store the result into an associative array so that we will be able to loop through the records.

The While Loop Loops through the result set and display the result inside the table data because we use table to display the result.

Example using MySQLi(Procedural):

Example using PDO:

The Output of the Code above looks as shown below.

select record


In summary, we have discussed here how to use MySQL select statement using PHP in MySQLi Procedural, MySQLi OOP, and PDO

If you have any questions or suggestions about this tutorial using PHP and MySQLi or PDO, please feel free to leave a comment below. 

Looking for more source code? Type your keyword here here!


  1. in this article i found some answer in my question and also deepen my understanding on how to use select query using php script.


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.