0% found this document useful (0 votes)
5 views5 pages

4 (B)

The document provides SQL UPDATE statements using the LIKE operator with both percent signs (%) and underscores (_). It includes examples for updating student city and marks based on specific conditions related to names and city names. Additionally, it shows how to update employee salary and department based on name patterns and department length.

Uploaded by

sharmasudip010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

4 (B)

The document provides SQL UPDATE statements using the LIKE operator with both percent signs (%) and underscores (_). It includes examples for updating student city and marks based on specific conditions related to names and city names. Additionally, it shows how to update employee salary and department based on name patterns and department length.

Uploaded by

sharmasudip010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Like with UPDATE Statement % (percent sign):

1) Update the city of those students whose Name starts with "S".

UPDATE Student SET City = 'Jaipur' WHERE Name LIKE 'S%';


Select * From Student Where Name LIKE 'S%' ;
2) Update the Marks of those students whose City name ends with "i"

UPDATE Student SET Marks = 70 WHERE City LIKE '%i';


Select * From Student Where City LIKE '%i';

3)Update the Marks of those students whose Name of the city starts with
"G" and ends with "d".

UPDATE Student SET Marks = 90 WHERE City LIKE 'G%d' ;


Select Roll_No, Marks, City From Student Where City LIKE 'G%d' ;
4)Update the City of those students of the above student table
whose Name contains the letter "a" in any position.

UPDATE Student SET City = 'Goa' WHERE Name LIKE '%a%' ;


Select * From Student Where Name LIKE '%a%' ;
Like with UPDATE Statement _ (underscore sign):

1) Update the salary of those employees whose Name contains "a" at the
second position.

UPDATE Employee SET Salary = 9000 WHERE Name LIKE '_a%' ;


Select * From Employee WHERE Name LIKE '_a%' ;
2) update the department of those employees whose name contains at
least 3 characters and starts with the letter "S"

UPDATE Employee SET Emp_Dept = 'Coding' WHERE Name LIKE 'S___%' ;


SELECT * FROM Employee WHERE Name LIKE 'S___%' ;

3) Update the Salary of those employees whose Emp_Dept is 2


Characters long and ends with the character 'R'.

UPDATE Employee SET Salary = 20000 WHERE Emp_Dept LIKE '_R' ;


SELECT * FROM Employee WHERE Name LIKE '_R' ;

You might also like