Selecting Data in MySQL
Selecting Data in MySQL
To select data from one or more tables in MySQL we can use the SELECT query. To select a single data in a table we use the following:
To select all columns from a table, we need to use the following:
Let's assume we want to select employeeID, firstname and lastname from the Employees table, then we want to display the result using fetch_assoc() inside a while loop.
Note: The function fetch_assoc() puts all the results into an associative array so that we can loop through. The while loop loops through the result set and outputs the data.