September 14, 2024
Select data from table using SQL
Select statement is one of the most important SQL statement. By making an appropriate select query, we can retrieve data we need. It allows you to specify which columns of a table we want to get, apply filters, sort the results, and more. The SELECT statement is one of the most commonly used SQL commands and forms the foundation for querying databases. Various examples are mentioned below:
Select query with specific columns and all columns
select student_name, math_marks, science_marks from student_info;
select * from student_info;
Select query with where clause
With order by clause, we can get select query output in ascending or descending.
select student_name, math_marks, science_marks from student_info where student_name='Ram Singh';
Select query with order by clause
With order by clause, we can get select query output in ascending or descending.
select student_name, math_marks, science_marks from student_info ORDER BY math_marks;
Select query with limit clause
With limit clause we can limit our select query output.
select student_name, math_marks, science_marks from student_info limit 10;