在解僱INSERT查詢時,是否有可能返回錯誤(或任何其他指示)如果我希望插入的值之一已經存在於表中?MySql重複返回錯誤
INSERT INTO `private_customers`(`first_name`, `phone_number`)
VALUES ('the_first_name','1122334455')
// if the phone number is already exist in the table then don't insert nothing and return indication that it is already exist
在'(phone_number)'上添加一個'唯一'約束? –
如果你不想創建'UNIQUE'約束,只需要1.'SELECT'來檢查電話號碼是否已經存在,2.你的INSERT',3.利潤。 – cypher
但是兩個私人客戶不能共享相同的號碼嗎? (例如,一對夫婦住在一起)。 – jarlh