Mysql, dont execute next statement if last insert was duplicate (nubie) -
I am trying to see that there is no way for me to migrate with just one big DB MySQL question , No php no INSERT ('name') Duplicate key update name = name in company (name) values; SET @companyID = LAST_INSERT_ID (); Include Phone 2 Companie (Company ID, PhoneID) prices (@ CompanyID, '3'); Include address 2 company in company page (company id, address) value (company ID, 'address');
The name is a unique column, so if I get a duplicate, it returns incorrect LAST_INSERT_ID (); And the rest of the questions are executed incorrectly.
Is there any way to put ISPL in mysql? Smth like:
IF (@companyID << @last_companyID) {Insert 1 .... Insert 2 ....}
You can create a function or stored procedure to do this. Another option is to use a case statement.
Comments
Post a Comment