MySQL SELECT Statement

Last updated on March 14, 2023

The SELECT statement selects the data from a table in the database. It can select all the available column values from a table in the shape of a row. Also, it allows you to select specific columns, in case you don’t need all the values.

Syntax

SELECT columnOne, columnTwo FROM tableName;

Usage

To understand the select statement, look at the table below which has students’ data that need to be fetched through the select query.

StudentIDStudentNameStudentClassStudentMarks
1Emily5th450
2John6th430
3Elon8th510
Student Table for Understanding Select Statement in MySQL

To fetch all the rows from the above students table, you need to use select statement with asterisk (*).

SELECT * FROM students;

The above select query fetches all the columns from the students table. To get specific columns from the students table, you can specify the columns’ names.

SELECT StudentID, StudentName  FROM students;

In this select query, we specified columns’ names with a select statement to fetch them. So it will be fetching only StudentID and StudentName columns’ data.


Written by
I am a skilled full-stack developer with extensive experience in creating and deploying large and small-scale applications. My expertise spans front-end and back-end technologies, along with database management and server-side programming.

Share on:

Related Posts