SQL Select Query and Use of Select Command | Learn DBMS | Tech-Mirror

SQL SELECT Query

  • SQL SELECT Query is used to getting orĀ  retrieve data from a table in the database. It is most commonly and highly used SQL statement in DBMS.
  • A query may give result from specified columns or from all of the columns in the table. To create a simple SQL SELECT Statement, you must specify the column(s) name and the table name in a query. The whole query is called SQL SELECT Statement.
  • In SQL Select Query, We can retrieve whole tables(all columns data), or partial by mentioning conditions using WHERE clause.
SQL Select Query | Tech-Mirror
SQL Select Statement | Tech-Mirror

Syntax of SQL SELECT Statement:

  • table-name is the name of the table in a specific database from which the information is retrieved.
  • columns_list includes one or more columns from a table-name which data is retrieved.
  • The code within the brackets is optional.

Note :Things to be Remember.

No. of Columns Syntax
All Select * FROM table_name
1 SELECT column_name FROM table_name;
Moew than 1 SELECT column_name1, column_name2, column_name3,..n FROM table_name;

Table : Student

ID First_Name Last_Name Username
1 Mahesh Shah mas
2 Krish Tripathi krt
3 Larry Page lap

Note : This database table are used here for better understand of SQL commands. In reality, the tables can have different columns and different data.

For example, consider the table Student. To select the first name of all the students the query would be like:

Note : SQL commands are not case sensitive. The above SELECT statement can also be written as

We can also get data from more than one columns. For example, to select first name and last name of all the students.

We can also get all columns data of a table. For Example, to get all information about Students.

Note : In a SQL SELECT Query only SELECT and FROM phrase are necessary. Other clauses like WHERE, GROUP BY, ORDER BY, HAVING are optional.

Leave a Reply

Your email address will not be published. Required fields are marked *