Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server : how to delete specific rows data with where condition in column?

I have a table with some columns and rows. I want to delete some rows contain specific data at specific row.

Ex: the table name is EXAM

enter image description here

I want to delete row 1 and row 3 when input condition string is C.

I did with the statement:

DELETE FROM EXAM 
WHERE Comumn2 = 'C' 

but only deleted Row 3.

like image 274
Tbn779 Avatar asked Oct 24 '25 11:10

Tbn779


1 Answers

To match rows which contain a specific value, use LIKE instead of =:

DELETE FROM EXAM WHERE Column2 LIKE '%C%'
like image 151
sgeddes Avatar answered Oct 26 '25 03:10

sgeddes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!