Using SQL, I have 5 columns: ssn, lastname, firstname, RF and flag field . I need to go through this table and where 4 columns are equal to another row and the flag field value in this row is 2050, then delete this entry 2050.
delete from MyTable m where flag = 2050 and exists ( select 1 from MyTable where MyTable.ssn = m.ssn and MyTable.lastname=m.lastname and MyTable.firstname=m.firstname and MyTable.RF=m.RF and MyTable.flag <> 2050 )
DELETE T1 FROM My_Table T1 INNER JOIN My_Table T2 ON T2.ssn = T1.ssn AND T2.last_name = T1.last_name AND T2.first_name = T1.first_name AND T2.RF_name = T1.RF_name AND T2.flag <> T1.flag WHERE T1.flag = 2050
delete from TableName as tn where tn.flag = 2050 and exists (select * from TableName as tn2 where tn.ssn = tn2.ssn and tn.lastname = tn2.lastname and tn.firstname = tn2.firstname and tn.rf = tn2.rf and tn2.flag <> 2050)
delete from Table1 where flag = 2050 and exists (select * from Table2 where ssn = Table1.ssn and lastname = Table1.lastname and firstname = Table1.firstname and rf = Table1.rf and flag <> 2050)
Source: https://habr.com/ru/post/1286705/More articles:Can I use PowerShell 1.0 to list processes along with their PID and commands? - powershellShould I give priority to the semantic marking of my pages? Or is the Semantic Internet a good idea that can never go crazy? - htmlDoes CC.NET check for modifications when the script build checks - cruisecontrol.netHow do you limit the Facebook application to a small number of people during testing? - facebookCreating a Java GUI - javahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1286706/wxpanel-scales-to-fit-entire-parent-frame-despite-giving-it-a-size&usg=ALkJrhhoi2NH30iYW99aFUF5nb5P2vEwagHow to generate a pseudo-random positive definite matrix with restrictions on off-diagonal elements? - mathHow to generate a pseudo-random positive definite matrix with restrictions on off-diagonal elements? - mathHow to stop Internet Explorer 8 pop-up bit selection? - jqueryLooks like a simple graphical task - mathAll Articles