Posts

Showing posts from August, 2020

Constraints in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Constraints in SQL". We have learn CRUD operations so far, now its time to advance our skills. We will again create a table with some properties and make our database table more reliable and effective. For making our database table more reliable and effective we are going to add some "Constraints" in our table.  So in this blog we are going to talk about What is constraints ? Types Of Constraint. Create a table with constraints. Let's start with 1) What is Constraint? Constraints are nothing but rules which a data row must satisfy to get inserted in database. For example: When a person wants to take flight he/she have to go through many checks like security, passport, boarding pass, etc. these checks are there to ensure only valid person can enter flight and flight will...

Update, Delete and Truncate Commands

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Updating and deleting data". We learn about "Inserting and Retrieving Data" in  this blog . Now its time to learn updating and deleting our mistakes. Yes with the help of the UPDATE and DELETE  statements  you can actually update and delete wrong entries in your database respectively. So in this blog we are going too talk about  UPDATE statement DELETE  statement TRUNCATE command Let's start with 1) UPDATE statement : UPDATE statement is used to update a specific record or a bunch of records which exists in your database table. If you made a mistake while inserting data in your database then UPDATE statement is the loophole through which you can correct it. Let's see a example: If you can see in our table I have made a mistake that SALARY  of "Sales Per...

More clauses in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about "More clauses in SQL". We learn about "WHERE" clause in this blog . Now its time to learn more clause which are going to help us to be more specific about retrieving data from Database and eventually its gonna make us more and more efficient in handling data in Database. So, In this blog we are going to talk about GROUP BY clause HAVING clause ORDER BY clause Now, let's talk about 1) GROUP BY clause This clause is often used with Aggregate Functions (which we have learnt in previous blog ) so that we can group our result with a particular column. I know it sound little confusing but we will solve this confusion with the help of example. Let's consider a scenario where I told you to count number of people working in each department with our existing Employee table. So then you might write a query like this: select count(*) from Employee where Department='IT' Then you will keep rep...

Aggregate Functions and like operators in SQL

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Aggregate Functions and like operators in SQL". In previous blog we have seen inserting and retrieving data from database, today we will see more combinations in which we can retrieve data and we will also see some of the functions which help us in performing some calculations. In this blog we will talk about : Aggregate functions LIKE operator 1) Aggregate Functions: Aggregate functions performs calculations on a set of values. Aggregate functions are also known as singled valued function because every time you use them you will get a single valued result. SQL has 5 aggregate functions : COUNT() MIN() MAX() AVG() SUM() One important thing is aggregate functions ignores null values ( when you don't enter value of a column while inserting a record then that column has null value that actually means "no value") except when it comes to count() aggregate function it considers null value. COUN...

Inserting and Retriving Data from Database

Image
Hello, and welcome to the blog. In this blog we are going to talk about "Inserting and retrieving data from database" in database. We have created a simple Employee table in our previous blog (  https://learntocodewithmustafapinjari.blogspot.com/2020/07/basics-of-sql.html  ). Now its time to add some data in that table and then we will see how we can retrieve that data. In this blog we will talk about : Inserting Data Retrieving Data Operators in SQL 1) Inserting Data : There are 2 syntax available in SQL for inserting data. Both are simple. Let's see them one by one Syntax 1 : insert into table_name values (value_1, value_2,........,value_n) Example : insert into Employee values(1, 'John', 'Doe', 'Sales',50000,'Sales Manager') In this syntax you have to make sure that you maintain the sequence of  values as per the sequence of column in the table. If you  miss a value or you add more values than number of column then you will get an error....