![]() |
|
MySQL Updating Error - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: MySQL Updating Error (/showthread.php?tid=2074) |
- Jaiz - 08-01-2013 Hello Coders, Im trying to update something to my Database t_shop. Its update succesfully but i get one error but i dont know why. Maybe you can help me to fix / soleving this problem. Its says me that i duplicate the key although i looked in the database the key isnt duplicated. Very strange problem. Here you can see on this Video my Problem: 2 Hope you can help me. ![]() Regards Jaiz - someone - 08-01-2013 The column that has primary key it has a constraint( to not let duplicates ID ),and it is used for tables relationships. Since you didnt post the Update SQL query, and in what I saw just a part of it, in what I saw is that you forgot to put the condition for the Query. Your current query is: UPDATE table SET columns=xxxx,coklumn2=yyyyyyyy Which without condition will apply to all rows in the table(the first row will change successfully and when it will apply the settings on the second row, it will pop up an exception about your constraint) : The proper method to use Update for a certain row is(this way will apply to the rows that columnX is zzz): UPDATE table SET columns=xxxx,coklumn2=yyyyyyyy WHERE columnX=zzz I suggest reading more about SQL. - Jaiz - 08-01-2013 Okey i try it out. Thanks |