12- MySQL Select Data


MySQL Select Data 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 Code above looks like as shown below.

select record

Our Previous Topic called: 11- MySQL Multiple Insert


Facebook Comments
  • Login
  • select record
    select record


Please enter your comment!
Please enter your name here

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