Mumlebumle Posted August 17, 2010 Share Posted August 17, 2010 Hi, Can i make so the mysql columns cant have the same number, such as if the row 1, column 1 have the value 30, and then the row 2 column 1 cant be 30, but can be 31?.. The problem is i have an auto increment id before thoose, and then the stuff being added will just keep being added, but just to a new id. hereby more of 1 type can occur. $sql = "INSERT INTO reimburse VALUES ('','$reimbursekillid','')"; mysql_query($sql)or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted August 17, 2010 Share Posted August 17, 2010 my your ID column the Primary column, set it as INT, and then set AUTO_INCREMENT on the column itself. This way unless you go changing the ID value through your scripts it will always be unique. If for some reason the row does manage to get and try to set a value already used it should throw an error as i think a primary ID column is also automatically set as unique which means it shouldn't allow a value that's already being used. Alternatively you can make your own auto increment system lets say if you want you're values to start at 20000 and count up rather than starting at 1 and going up from there.. but all in all its the applying the same idea, and in the case of your own your just making extra calls to the DB to increment a number and insert it else where. Quote Link to comment Share on other sites More sharing options...
Mumlebumle Posted August 17, 2010 Author Share Posted August 17, 2010 my your ID column the Primary column, set it as INT, and then set AUTO_INCREMENT on the column itself. This way unless you go changing the ID value through your scripts it will always be unique. If for some reason the row does manage to get and try to set a value already used it should throw an error as i think a primary ID column is also automatically set as unique which means it shouldn't allow a value that's already being used. Alternatively you can make your own auto increment system lets say if you want you're values to start at 20000 and count up rather than starting at 1 and going up from there.. but all in all its the applying the same idea, and in the case of your own your just making extra calls to the DB to increment a number and insert it else where. Thanks, i found the unique button beside the primary and used that one, it worked, now getting Duplicate entry '30' for key 'kill_id' :D Quote Link to comment Share on other sites More sharing options...
monkeytooth Posted August 17, 2010 Share Posted August 17, 2010 If you don't have a lot of data built up yet, it may be in your best be to just "EMPTY" the whole table it leaves the structure but everything in it that stored is wiped out of it. Chances are since your applying the auto_incriment / unique to a table thats already been built and used its running into that error you gave cause the auto incriment value in the tables "Operations" tab is either below a number already existing in the table or. You have 2 or more rows where the ID is the same. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.