The INSERT INTO command can be used to insert a single row or multiple rows into a table. The DELETE command can be used to delete a single row or multiple rows in a table. The UPDATE command can be used to update a single row or multiple rows in a table. To show only the sales decrease, we use the WHERE clause. In it, we again subtract the third quarter from the fourth and set the condition that the result has to be below zero, i.e. a decrease.

Basic SQL commands

We write the first table’s alias (instead of its full name), separate them with a dot, and then the column name. We put the equal sign, the second table’s alias, and the column name. This type of query is used whenever you want to access data from two or more tables. We’ll show you INNER JOIN, but it’s not the only join type you can use. The query will show the total salary by department, but it will include only individual salaries above $3,500 in the sum.

SQL Commands: Data Control Language Commands (DCL)

JOIN, also called Inner Join, selects records that have matching values in two tables. COUNT will count the number of rows and return that count as a column in the result set. ORDER BY gives us a way to sort the result set by one or more of the items in the SELECT section. Here is an SQL sorting the students by FullName in descending order.

This clause used to combine two SELECT statements and return the intersection of the data-sets of both the SELECT statements. This statement goes through all the conditions and returns a value when the first condition is met. So, if no conditions are TRUE, it returns the basis sql value in the ELSE clause. Also, if no conditions are true and there is no ELSE part, then it returns NULL. The SUM function returns the total sum of a numeric column that you choose. The COUNT function returns the number of rows which match the specified criteria.

Q. Get the names of all of the artists.

This command is used to withdraw the user’s access privileges given by using the GRANT command. Let’s consider the below table apart from the Employee_Info table, to understand the syntax of joins. In this section of this article on SQL Commands, you will go through the Aliases and Case statement one after the other. The EXISTS operator is used to test if a record exists or not.

  • The query is almost exactly the same as in the previous example.
  • This constraint ensures that all the values in a column satisfy a specific condition.
  • A database is the organized collection of structured data which is usually controlled by a database management system (DBMS).
  • But we already did that for you in our SQL Basics course.