Skip to main content

Posts

Showing posts from July 1, 2019

Select Statement in SQL

Select Statement in SQL Select statement is most used command in SQL. It is used to fetch data from table and display data in tabular form. The syntax of select statement is: SELECT *FROM Table_Name; Suppose we have a below EMP table Emp_ID Emp_Name Emp_Age Emp_Salay 1 Mohan 25 25000 2 Rakesh 25 25000 3 Ram 25 25000 Now we have above table which is already created and now we want to fetch all table data from above table so for this we use below Select statement to retrieve SELECT Statement to retrieve Data from EMP table: SELECT *FROM EMP ; Now after executing this command , the output will be : Emp_ID Emp_Name Emp_Age Emp_Salay 1 Mohan 25 25000 2 Rakesh 25 25000 3 Ram 25 25000

Insert multiple row values in SQL table

Insert multiple row values in SQL table In this post, you will learn how to insert values in table by using INSERT Command. INSERT command is used to insert values in Table of your database. By using INSERT statement you can easily add value in your table: Syntax of INSERT statement: INSERT INTO Table_Name ( Column1, Column2, Column3....)  Values(values1, values2, values3 ....etc), (values1, values2, values3 ....etc), (values1, values2, values3 ....etc), (values1, values2, valuesn ....etc) Here first you need to use INSERT INTO command and then you need to specify table name in which you want to add values. Then you need to specify column name and then need to mentioned values based on datatype. Now lets see an example: I'm going to insert value in EMP table Emp_ID Emp_Name Emp_Age Emp_Salay Insert values in EMP table: INSERT INTO EMP (Emp_ID, Emp_Name, Emp_Age, Emp_Salary) Values (1, 'Mohan', 25, 25000), (2, 'Rakesh...

Update command in SQL

How to use UPDATE Command in SQL In this post, you will learn how to use UPDATE command in SQL. UPDATE command is used to update existing record in table. Update command is always used with WHERE clause. If you don't use WHERE Clause, all record will be updated in table so while using UPDATE command, you must be carefull. Syntax of UPDATE command: UPDATE Table_Name  SET Column_Name='New_Values'  WHERE Column_Name='Old_Values' ; Suppose we have source table:  Emp_ID Emp_Name Emp_Age Emp_Salay 1 Mohan 25 25000 2 Rakesh 25 25000 3 Ram 25 25000 Now i'm going to update Emp_Name: Mohan to "Mahesh". Now use below code to Update existing record UPDATE EMP  SET Emp_Name='Mahesh' WHERE Emp_Name='Mohan'; Now after executing this code, you will get below results: Emp_ID Emp_Name Emp_Age Emp_Salay 1 Mohesh 25 25000 2 Rakesh 25 25000 3 Ram 25 25000 Update M...