By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,500 Members | 2,766 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,500 IT Pros & Developers. It's quick & easy.

Insert record unless duplicate for non-key field (except when empty)

P: 2
I am interested in doing a record insert into a mysql database unless a specific field is a duplicate. two relevant points:
1) I prefer to not make the given field a key unless required
2) an insert should be allowed for when the form field is left blank by the user

any tips to prevent a duplicate record being enterred except as described above?

Thank you!!
Mar 10 '12 #1
Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,366
Create a unique index on the field.
Mar 10 '12 #2

P: 2
@Rabbit
what should I do about allowing the field to be empty when the form is submitted? the table already has existing "blank" entries for that column. do I need to set a default? do I need to do anything with the existing "blanks" since I am getting a #1062 error when trying to set unique?

sorry for the beginner questions.
Mar 10 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.