Thursday, May 20, 2021

SQL Concept-Part 2


 In this blog we are going to understand the important and basic concepts of SQL...


 1.How can we create composite key?

  • The PRIMARY KEY constraint uniquely identifies each record in a table.
  • The combination of two or more columns that are used for unique identification of row in table.
  • composite key specifies multiple columns for a primary-key.
 








2.How to write simple SQL with where clause?
  • Firstly type the select query required column name,table name and where clause.
  • In this, where clause is used to put condition and get specific records.
  • The WHERE clause is used to filter records.


Example:

   





Output:





3.How to select specific column name in select query?
  • To select required column or we can say specific column we have to declare column name and from which table do you need it

Example:







Output:


         



4.What is an ALIAS in SQL Server?
        ALIAS  are used to give a table, or a column in a table, a temporary name. Aliases are often used to make column names more readable. 

Example:





5.What is difference between Inner join vs Left join vs Right join?

Inner Join:
     INNER JOIN keyword selects all rows from both the tables as long as the condition satisfies. Inner join displays the matching records from two or more tables.

Example:

   




Output:
                  
    
                                                                                                             


Left Join:
   This join returns all the rows from left table combine with the matching rows of the right table. If you get no matching in the right table it returns NULL values.

Example:

                                                                                                            



                                  

Output:

    


Right Join:
     this join returns all the rows from right table are combined with the matching rows of left table .If you get no column matching in the left table .it returns null value.


Example:

  
  




Output:

  



 

For more understanding watch below video :




thank you!!!!



 





No comments:

Post a Comment

Function in SQL -part 8

  In this blog we are going to understand  Sql function.   FUNCTION: A function is a database object in SQL Server. It accepts only input pa...