View Full Version : Adding a unique record to DB

12-23-2010, 02:49 AM
I want to create a contest page, and the contest ID I want to be unique, it'd mess things up if two contests were the same number.

Using RAND won't work. How can I insert a record that is unique into mysql?

12-23-2010, 02:52 AM
Set it to auto_int as that way it will make the number itself like a primary ID number once auto_int is active on a table column and a row is added it will auto put the number in.

12-23-2010, 04:07 AM
Do I have to make it a primary key? and also do I insert any value for it, or will it auto insert a number?

12-23-2010, 04:28 AM
If its auto_int the mysql query for inserting a new row will insert the id number for you so you wont need to worry about the ID and yes you will need to make it a Primary Key.