Insert/Update/Delete data

Insert Data

Now we will add some data using the SQL insert query

Insert query pattern:

insert into table_name (column1,column2,column3,……..columnN) values (‘value1′,’value2′,’value3′,……….,’valueN’);

Now insert some data into our newly created table using this query:

INSERT INTO employees (Emp_id,FirstName,LastName,Department,Designation,Salary) VALUES ('1001','Abdur', 'Rahim','IT','IT executive','25000');

Execute this query to the SQLyog. Do not forget to start the xampp server before starting the Sqlyog software.

Now you see, 1 query executed. That’s mean, you have inserted a data to your employees table.

Now right click to your table name and click on “Open table”

You will see the data. If you can’t see data, then click on the refresh button.

Now insert multiple data executing the following query:

INSERT INTO employees (Emp_id,FirstName,LastName,Department,Designation,Salary) VALUES 
('1002','Abdul', 'Karim','IT','IT executive','25000'),
('1003','Shafiqur', 'Rahman','IT','Manager','35000'),
('1004','Hafizur', 'Rahman','Marketing','Executive','22000'),
('1005','Hafizur', 'Rahman','Marketing','Executive','22000'),
('1006','Md.', 'Halim','Marketing','Manager','35000')

Update Data

Update query pattern:

update table_name set column1='value1', column2='value2', column3='value3',........columnN='valueN' where id=@id;

“@ means value of of the column”

Now we will update an employee designation and salary using this query:

UPDATE employees SET Salary='30000', Designation='Sr. IT executive' WHERE Emp_id='1001';

You will find the Id 1001 has been updated.

Delete Data

Delete query pattern:

delete from table_name where id=@id

Now we will delete an employee data who has id 1006

Execute the following query to delete data:

DELETE FROM employees WHERE Emp_id='1006';

You will find the 1006 id has been deleted.

about author


If you like my post or If you have any queries, do not hesitate to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *