EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials SQL Tutorial SQL Commands
 

SQL Commands

Priya Pedamkar
Article byPriya Pedamkar

Updated March 2, 2023

SQL Commands

 

 

Introduction to SQL Commands

SQL or popularly known as Structured Query Language, is the fundamental query language for databases and is a domain-specific language for Relational Database Management Systems. It is useful when the data type is structured and there exists a dependency among the various attributes of data. It is widely used and is one of the most popular query languages for its unique capability of fetching multiple records by just making use of a single query statement. It consists of both DDL (Data Definition Language) and DML(Data Manipulation Language) commands which makes the use of queries much more efficient. SQL is a declarative programming language that is set-based and is therefore not an imperative programming language such as C or BASIC, etc. In order to fetch the data results from the database, you need to know SQL commands which we are going to study in this post.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Basic SQL Commands

The basic commands are given below.

1. SELECT: This is possibly the most basic SQL command. The select command is used to fetch or retrieve results from a particular table of a database. This is generally followed by specific column names or all column names (by making use of * ).

Basic SQL Commands Select

2. CREATE: This is one of the basic DDL commands which is used to create a table inside a database. The prerequisites of creating a table include knowing column name and their datatypes.

Basic SQL Commands Create

3. ALTER: This DML command is used to make alterations to the table. It includes modifying the table as per the need.

Basic SQL Commands Alter

4. WHERE: The WHERE clause is one of the most important SQL commands as it is used to retrieve or fetch the specific data that is required for a particular case. This is helpful as it excludes all the irrelevant data.

Where

5. SQL ALIAS: The ALIAS is among the most common SQL command which is used to give a meaningful name to your attribute or a column. They are defined for columns and tables, which helps in increasing the readability of the query.

SQL Alias

6. AND: This is an SQL operator which is used to combine two conditions. For the row to appear in the data result set, both the conditions should be true.

Basic SQL Commands AND

7. AVG(): This is an aggregate function that is used to return the average value of a particular numeric column.

AVG()

8. ORDER BY: This is used along with the select statement to sort the results either in ascending order or descending order. If no argument is given after the ORDER BY clause, it by default takes as the ascending order query.

Basic SQL Commands ORDER by

9. GROUP BY: The GROUP BY clause in the SQL commands is used to retrieve the data on the basis of some particular grouping related to one or more columns.

GROUP BY

10. INSERT: The INSERT command is used to add a new row of data inside the table. The mandate for the INSERT command is that the table should be already created.

Insert

Intermediate Commands

The intermediate commands are given below:

1. UPDATE: This command is used to update or modify the existing rows in a table.

Intermediate SQL Commands UPDATE 1

2. DELETE: As the name suggests, this command is used to delete the rows from a table.

Deleted

3. HAVING: The HAVING clause is used to filter the data based on one or more group functions. This is quite very similar to using a WHERE clause but this includes the use by a group function.

Intermediate SQL Commands Having

4. LIKE: This operator is used to compare between the two conditions and lists down all the rows of a table whose column name matches the pattern specified with the LIKE clause. Wildcard operators such as % are used when you are not sure about the particular pattern.

Like

5. IN: The IN operator when the comparison of a column is made with multiple values. It is more or less similar to the OR condition.

In

6. IS NULL: The IS NULL operator is another SQL-based operator which is used to display whether the particular column name has a NULL value. It is used to fetch all the rows for the specified columns for which the data has not been found or has been found as null.

Is null

7. BETWEEN: As the name suggests, this operator filters the results for a particular set of ranges. The value, in this case, can either be numbers, dates or text.

Between

8. CASE: This case is the same as used in other programming languages such as Java, etc., where a decision control statement is taken by the case statement and the argument inside it is used to fetch the case results matching the particular condition.

Intermediate SQL Commands CASE

9. COUNT(): This is one of the most useful SQL commands which is used to display the count of the total number of rows for all those non-null data. It makes use of the column name as the argument.

COUNT

10. INNER JOIN: This is one of the most important SQL commands which comes into play when there has to build a relationship among the attributes of two tables based on a fixed common attribute. In other words, the join condition has to be true in order for INNER JOIN to function.

Inner join

Advanced SQL Commands

The advanced commands are given below:

1. LIMIT: The LIMIT clause will help you specify the maximum number of rows that are allowed in the result set.

Advanced SQL Commands Limit

2. OUTER JOIN: This is the join function that comes into play when all the fields of both tables are required based on some common input column condition. If the join condition is not met, then a NULL value will be filled on the right side of the column.

Outer join

Tips and Tricks to use SQL Commands

Whenever you are using SQL commands, spend more time analyzing the table than querying and executing it. Make use of simpler and less complex queries with minimum use of dynamic SQL. Also, we prefer to use a table alias for better readability.

Conclusion

This post was about the important SQL commands which form the base of the database querying language.

Recommended Articles

This has been a guide to SQL Commands. Here we have discussed basic, intermediate as well as advanced SQL commands along with tips and tricks to use. You may also look at the following article to learn more-

  1. SQL GROUP BY WHERE
  2. SQL Server Versions
  3. SQL now
  4. sql projects

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW