SQL | All you need to know as a beginner


The Most Used syntax of SQL is Select. Select statement used to select data from the database.

To select specific column use

To select all from the table


Distinct means different. It removes duplicate values from the column.

If there is a table that contains the same country two times it will keep one and remove others.


Group by works same as Select Distinct work.

4. Select Distinct vs Group By

Both work with a number of return rows and remove the duplicates.

Group by mostly used with aggregate functions such as SUM, COUNT, AVG, MAX, MIN.

5. WHERE clause

To filter the search result where clause us mot sued one.

6. AND, OR, and NOT Operators

AND, OR, and NOT operators make WHERE CLAUSE more specific to filter the values.

OR — If any one of the condition is true it will work

AND — If all the conditions work result came true it will work

NOT — If the conditions are not true NOT operator will work.

All work together.


To sort the result set in ascending or Descending order we use ORDER BY.

The Default sorting order is Ascending. We can pass multiple column names for sorting.

It will check the first column and then the second and so on.


This statement used to a new record in a table.

We can add data in two ways. First, one specifies the column name and then provide value,

The second one, If you want to add values in all columns, you don't have to add provide column name.

Insert data in a specific column.


To add a field without value we use NULL. Later you can update with the original value.

IS NULL: If any field value is empty and we need to check then we use IS NULL for an empty value.

NOT NULL: To check the non-empty value on a field we use this condition.


To replace/update the value of the existing column we use this statement.


To delete a record from a table we use this statement.

To delete a row you need to provide conditions else all records will be deleted.

For Example.

To delete a single row

To delete the entire record:


To return the specific number of records we use LIMIT.

12. MIN & MAX

- MIN returns the smallest value of the selected column.

- MAX returns the largest value of the selected column.

13. COUNT()

COUNT() return the total number of rows.

14. AVG()

AVG() return the average of the numeric value of the selected column.

15. SUM()

SUM() return the sum of the numeric value of the selected column.

Part 2 is coming soon.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store