10 Most Common SQL Queries That You Should Know
Last Updated :
14 Feb, 2023
To handle huge amounts of data, companies rely on SQL which stands for Structured Query Language which is used to communicate with the database. It provides a path through which we can access the database without going through complicated procedures. All the operations you can do follows the CRUD acronym.

CRUD stands for the four most important operations that you can perform on a database: Create, Read, Update, and Delete.
In this article, we’ll discuss the Top 10 Most Common SQL Commands and Queries that can help you as a developer when you work with databases while building applications.
What is SQL?
SQL is a language/query used to manage data stored in relational databases. It allows you to create table, modify it, search for the data in the database. SQL contains queries used to modify changes in the existing table or creating a new table.
10 Most Common SQL Queries
1. Create a Table
CREATE statement in SQL is used to create a new table in your database.
Syntax to CREATE a table:
CREATE TABLE table_name(column1 datatype, column2 datatype, … columnN datatype);
Below is the query to create a table employee in your database:
CREATE TABLE Employee (EMP_ID int, NAME varchar (255), SALARY int, AGE int);
Output:
2. Select Query
SELECT is the most commonly used statement in SQL. The SELECT Statement in SQL is used for viewing all records from a table. The data returned is stored in a result table. These result tables are called result sets.
Syntax to SELECT a query:
SELECT column1, column2, columnN FROM table_name;
where, column1, column2… are the names of fields of a table, table_name is from where we will fetch the records.
Sample Table: Employee (table_name)
EMP_ID | NAME | SALARY | AGE |
1 | Rajesh | 25000 | 30 |
2 | Suresh | 30000 | 45 |
3 | Andy | 28000 | 40 |
4 | Charlie | 40000 | 36 |
Below is the query to fetch the fields EMP_ID, NAME, and AGE from the table Employee:
SELECT EMP_ID, NAME, AGE FROM Employee;
Output:
EMP_ID | NAME | AGE |
1 | Rajesh | 30 |
2 | Suresh | 45 |
3 | Andy | 40 |
4 | Charlie | 36 |
Below is the given syntax, if you want to fetch all the fields in the table:
SELECT * FROM table_name;
To fetch all the fields from the table Employee:
SELECT * FROM Employee;
Output:
EMP_ID | NAME | SALARY | AGE |
1 | Rajesh | 25000 | 30 |
2 | Suresh | 30000 | 45 |
3 | Andy | 28000 | 40 |
4 | Charlie | 40000 | 36 |
3. Insert Query
The INSERT Statement in SQL is used to insert records into a table. The INSERT INTO declaration is used to insert new records in a table.
Syntax to INSERT a tuple:
INSERT INTO table_name (column1, column2, … columnN) VALUES (value1, value2, … valueN;
Here, column1, and column2… are the names of fields of a table.
Below is the query to add the fields EMP_ID, NAME, and AGE in the table Employee:
INSERT INTO employee (EMP_ID, NAME, SALARY, AGE) VALUES ('1', 'Rajesh', 25000, 30);
Output:
EMP_ID | NAME | SALARY | AGE |
1 | Rajesh | 25000 | 30 |
Adding more records to the employee table:
INSERT INTO employee (EMP_ID, NAME, SALARY, AGE) VALUES ('2', 'Suresh', 30000, 45);
INSERT INTO employee (EMP_ID, NAME, SALARY, AGE) VALUES ('3', 'Andy', 28000, 40);
Output:
EMP_ID | NAME | SALARY | AGE |
1 | Rajesh | 25000 | 30 |
2 | Suresh | 30000 | 45 |
3 | Andy | 28000 | 40 |
4. Delete Records From a Table
The DELETE Statement in SQL is used to delete some selected records from a table.
Syntax to DELETE a record:
DELETE FROM employee WHERE [condition];
Below is the query to delete the record from the table Employee:
DELETE FROM employee WHERE EMP_ID = '1';
Output:
EMP_ID | NAME | SALARY | AGE |
2 | Suresh | 30000 | 45 |
3 | Andy | 28000 | 40 |
4 | Charlie | 40000 | 36 |
5. Update Data in Records From a Table
The UPDATE Statement in SQL is used to update/modify the data in the existing records from a table.
Syntax to UPDATE records:
UPDATE table_name SET column1 = value1, column2 = value2, … WHERE [condition];
Below is the query to delete the record from the table Employee:
UPDATE employee SET age = 38 WHERE EMP_ID = '4';
SELECT * FROM employee;
Output:
EMP_ID | NAME | SALARY | AGE |
2 | Suresh | 30000 | 45 |
3 | Andy | 28000 | 40 |
4 | Charlie | 40000 | 38 |
6. Viewing Only Selected Records From a Table
Using this query, we can get only the selected records from the table.
Syntax to view only the selected records:
SELECT COUNT (1) FROM table_name;
Below is the query to view only the selected records from the table Employee:
SELECT COUNT (1) FROM employee;
Output:
EMP_ID | NAME | SALARY | AGE |
2 | Suresh | 30000 | 45 |
7. Viewing Records From a Table
Using this query, we can get the selected records without knowing the exact details from the table.
Syntax to UPDATE records:
SELECT * FROM table_name WHERE [condition];
Below is the query to view the records from the table Employee without knowing the details:
SELECT * FROM employee WHERE name LIKE 'a%y';
Output:
EMP_ID | NAME | SALARY | AGE |
3 | Andy | 28000 | 40 |
8. Where Query
Below is the query to retrieve records using more than one condition using the WHERE statement from the table:
SELECT * FROM employee WHERE name = 'Andy' AND age = 40;
Output:
EMP_ID | NAME | SALARY | AGE |
3 | Andy | 28000 | 40 |
You can also merge AND & OR to the WHERE statement.
9. Viewing Only Selected Columns From a Table
Below is the query to view only the selected columns from the table Employee:
SELECT name FROM employee WHERE age > 39;
Output:
You can also select more than one column from the table:
SELECT name, emp_id FROM employee WHERE age > 39;
Output:
10. Performance of the Query
Below is the advanced query which is useful if you need to get why a query is so slow.
EXPLAIN QUERY PLAN SELECT * FROM EMPLOYEE;
This query gives you the query cost of all the operations done.
Conclusion
SQL is easy to learn and it enables you to perform many operations with high efficiency and speed. SQL is a massive technology and it is continuously developing new features in every field. A software developer can use Structures Query Language(SQL) for manipulating data, building applications, and also for database-driven tasks. Although the list is not just limited to this, these were the top 10 most common SQL queries for beginners. These SQL queries will help all of the developers to use them while building the applications.
Related Resources
Similar Reads
7 Reasons Why You Should Learn SQL in 2024
SQL is pronounced as "sequel" by some while "S-Q-L" by others. SQL is an acronym for Structured Query Language, a standard and widely accepted language used for database maintenance by performing operations such as retrieval and manipulation of data stored in a database. SQL has been in existence si
7 min read
How to Log SQL Queries?
SQL (Structured Query Language) is the standard language for interacting with relational databases, allowing users to retrieve, manipulate, and manage data. Logging SQL queries is a crucial aspect of database management and performance monitoring. SQL query logging involves the systematic recording
6 min read
PL/SQL Common Table Expressions
PL/SQL Common Table Expressions (CTEs) make complex queries easier to write and understand by creating temporary result sets. We can use it multiple times in the same query. They help organize and simplify your code, especially for handling hierarchical data or recursive relationships. CTEs make you
10 min read
SQL Query to Get Column Names From a Table
SQL stands for Structured Query Language. It is a language used to interact with the database, i.e to create a database, to create a table in the database, to retrieve data or update a table in the database, etc. SQL is an ANSI(American National Standards Institute) standard. Using SQL, we can do ma
2 min read
MySQL Common Table Expressions
One of the most powerful features added in MySQL version 8.0 is common table expressions, which allow for the construction of temporary result sets within a single SQL query. In our daily life queries, we often use common table expressions and it makes our work easier. In this article, we will under
6 min read
SQL Query to Find the Number of Columns in a Table
SQL stands for a structure query language, which is used in the database to retrieve data, update and modify data in relational databases like MySql, Oracle, etc. And a query is a question or request for data from the database, that is if we ask someone any question then the question is the query. S
4 min read
How much SQL do you need to know as a developer?
For any software developers SQL is very essential to learn as they may come across a situation where they have to deal with SQL queries to manage data stored in the database. Having a strong grip over SQL queries makes it easy for developers to manage data more easily. From simple(Select query) to a
8 min read
SQL Query to Find the Sum of all Values in a Column
In SQL, calculating the sum of values in a column is a crucial task for performing data analysis and generating reports. The SUM() function helps to calculate the total sum of numeric values from a column, which is especially useful in scenarios like finding total sales, total employees, or total re
5 min read
SQL Interview Questions asked in Top Tech Companies
1.What do you understand by Adaptive query processing launched in SQL Server? Answer: SQL Server and Azure SQL Database introduce a new generation of query processing improvements that will adapt optimization strategies to your application workloadâs runtime conditions. 2.Name all three Adaptive que
4 min read
Nested Queries in SQL
Nested queries, also known as subqueries, are an essential tool in SQL for performing complex data retrieval tasks. They allow us to embed one query within another, enabling us to filter, aggregate, and perform sophisticated calculations. Whether we're handling large datasets or performing advanced
7 min read