Retrieving/fetching data using SQL

Last updated: April 26, 2023

To retrieve data from table, SELECT query is used. It return data set from database in a specific table.

Syntax:

SELECT * FROM table_name;

A database table have multiple column. For retrieve all columns of the table, asterisk("*") symbol is used.  For retrieving specific columns, asterisk("*") symbol replace by columns name.

SELECT column1, column2, column3 .... FROM table_name;

Fetch or retrieve all data from database table:

According to this course, previously we create a database table that name is contact and database name is account. we fetch all data from contact table.

Please make sure you are entering account database.

SELECT * FROM contact;
fetch all data from table

Fetch or retrieve data with specific columns from database table:

 

SELECT name, mobile FROM contact;
fetch data from database table with specific column

 

Related post