This is MS SQL code
if not exists (select PId from Person where Name = 'Name1' and Surname = 'Surname1') INSERT INTO [someDb].[dbo].[Person] ([Name] ,[Surname]) VALUES ('Name1' ,'Surname1')
Could you help me write ekvivalent code for my sql
thank
Assuming you have a unique index (first name, last name), you can use INSERT IGNORE:
INSERT IGNORE INTO `someDb`.`Person` (`Name` ,`Surname`) VALUES ('Name1' ,'Surname1')
In MySQL , this is usually done. I usually did this before I saw another answer with
INSERT INTO table (fields) VALUES (values) ON DUPLICATE KEY UPDATE ID=ID;
In your case, columns (Name, Surname) will be required for the UNIQUE index
Source: https://habr.com/ru/post/1785082/More articles:Import CSV file with null values in phpmyadmin - sqlHow to move from ASPX to the razor view engine in ASP.NET MVC 3? - asp.net-mvcHow to get the character encoding supported by a font programmatically? - c #Как заставить ListView правильно отображаться после нажатия на кнопку onClickListener? - androidXML encoding fix - pythonHidden orientation problems with orientation UIView / Layout - ioshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1785084/convert-an-array-of-string-arrays-to-a-hash-of-string-and-float-in-ruby&usg=ALkJrhjsad64RxW1fzw3vp5j7lZt_A451wWhen implementing WizardExportResourcesPage, how can I change the selected resources? - exportThe terms of the program through the terminal - c ++Google Analytics with Disabling MonoTouch on Device - iphoneAll Articles