SQL select query is used to fetch records from database. Select can use with clause and without clause. Select query returns number of rows from table.
SQL query example explains how to use select query in SQL.
select * from class_name;
* indicates fetch all columns records from table.
select Roll_No, Name, Class_Name, Year_Start from class_name;
This select query returns only selected column records from table name
select Name, Class_Name from class_name;
This select query returns only records with name and class_name columns
Output
+---------+-------------+------------+------------+ | Roll_No | Name | Class_Name | Year_Start | +---------+-------------+------------+------------+ | 1 | Amit Mishra | B Science | 2005 | | 2 | Robot | B. Tech | 2005 | | 3 | Rohan | M.Tech | 2005 | | 4 | Vivek | B.Tech | 2009 | | 5 | Chander | B.Science | 2009 | | 6 | Deepak | B.Science | 2009 | +---------+-------------+------------+------------+
select Name, Class_Name from class_name;
+-------------+------------+ | Name | Class_Name | +-------------+------------+ | Amit Mishra | B Science | | Robot | B. Tech | | Rohan | M.Tech | | Vivek | B.Tech | | Chander | B.Science | | Deepak | B.Science | +-------------+------------+




Link to Us