Open In App

How to Append Data to a SQL Column?

Improve
Improve
Like Article
Like
Save
Share
Report

In this Article we will update a record while keeping the existing record value if it exists. Whenever we need to just update the record after some time of creation the record

We will use Append Query in SQL. For Implementing the Append Query in SQL Here First of all we will create Database and inside the we will create a table with some Record.

Step 1: Create a Database

 For database creation there is query we will use in SQL Platform, like Mysql, oracle, etc.

Query:

Create database Sample;

Step 2 : Use Database 

After creation of database for using the database we will use a another query in SQL Platform like Mysql, oracle etc.

Query:

Use Sample;

Step 3: Creation table in Database

For creation a table in a database. We need to execute a query in SQL Platform. Like Mysql, Oracle etc. We will use this query ->

Query:

CREATE TABLE EMP1
( EMPNAME VARCHAR(25),
DEPT VARCHAR(20),
CONTACTNO BIGINT NOT NULL,
SALARY INT
); 

Step 4: To View schema of a table

Query:

EXEC sp_help EMP2021 

Output:

 

Step 5: Insert data into table

To insert data into table there is query we will use here in SQL.

Query:

INSERT INTO EMP2021
VALUES ('VISHAL','EXECUTIVE',9193458625,20000),
('VIPIN','SYSTEM ENGINEER',7352158944,32000),
('ROHIT','EXECUTIVE',7830246946,21000),
('RAHUL','SYSTEM ENGINEER',9635688441,35000),
('SANJAY','SYSTEM ENGINEER',9149335694,36000),
('ROHAN','MANAGER',7352158944,50000),
('RAJESH','SYSTEM ENGINEER',9193458625,30000),
('AMAN','MANAGER',78359941265,52000),
('RAKESH','SYSTEM ENGINEER',9645956441,29000),
('VIJAY','EXECUTIVE',9147844694,20000);

Step 6 :Verifying Inserted data 

After Inserting data in table We can confirm or Justify which data we have insert correctly or not. With the help of given Below Query. 

Query:

SELECT * FROM EMP2021;

Output:

Step 7: APPEND DATA IN SQL COLUMN

After Inserting the data in table now we will come on the last step of append Data in SQL Column Means update the data of existing Column Value with the help of Append Query. Here we will append data in Column(DEPT) . We will append SENIOR with SYSTEM ENGINEER Where SALARY is Greater then 30000 and less Then 50000.

Query: 

UPDATE EMP2021 SET DEPT = 'SENIOR '+ DEPT WHERE SALARY >30000 AND SALARY <50000; 

After Executing this query Column DEPT value will append with SYSTEM on the basis on Condition Where Salary is greater 30000 and Less then 50000. Changes we can see below

Output:


Last Updated : 12 Dec, 2021
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads