MySQL SELECT Query is used to fetching the data from the database. The MySQL SELECT Query is also used in a scripting language like PHP, Java, Ruby, etc. or you can execute it via the CMD command prompt.
How to fetch data from MySQL database
The MySQL SELECT Query is used to fetch data from one or more tables in the MySQL database:
You can fetch a specific column by using the below select statement.
SELECT STATEMENT SYNTAX
SELECT columnname FROM tablename
OR you can print all the columns by using the (*) character in the select statement.
MySQL SELECT statement will retrieve all records from a testrecords table without using any where clause. The below SELECT statement will fetch all records from testrecordstable.
You can use the SELECT statement into a PHP function mysqli_query() to execute the select query in the Mysql database and the mysqli_fetch_assoc function will return an associative array that array can be used in while loop to print output of each row.
The following example will display all the records from testrecords table using the PHP mysqli function.