By: Prem Tiwari | Last Updated:
In this tutorial, you will learn how to write a MySQL select query to fetch data from MySQL database tables. We have an option to fetch records of all fields or only the specified fields. Below is the example for both:
User the below MySQL query to fetch the all records from a MySQL tables:
SELECT * FROM
Above mysql query will fetch all records from the employee table which related to the HR department.
You can the below query to fetch data based on some specified fields from the database table:
SELECT emp_id, emp_name, emp_dept FROM
Use the below mysql query to fetch the records from multiple tables using the mysql inner join.
SELECT employee.dept_id, employee.employee_name, dept.dept_id, dept.dept_name
INNER JOIN dept
ON employee.dept_id = dept.dept_id
ORDER BY dept_id ASC;