I have a live project more than 5 years. And today i had a weird mistake. I wanted to update some of my products. And there exists a duplicate entry error.
I have no field as product_id in my products table. 12479 is id of my product. id is primary key and auto increment.
Firstly, i think it can be an laravel problem. I query mysql directly via phpmyadmin. It is same. But only for this product.
Here is my indexes.
Here is my table structure
I repaired my db from plesk also. Nothing change. Sometimes it works correctly.
Error from phpmyadmin
And the weirdest one is, this error occured when i update stock_quantity field. I can update other fields without problems.
I noticed a mysql bug while searching
MySQL Bug: https://bugs.mysql.com/bug.php?id=68360
What should i do ?
I solved problem. (Mysql Error Handling is not good. Descriptions must describe the situation better)
I had a trigger for stock_quantity. If a product sold out and get in stock again. I'm sending mail to customers. In that table(products_notify) product_id is unique. And the products which has ids on products_notify fails.
Thanks #Rodrane
Related
I am trying to create a database under phpmyadmin and add fields to it. but when I choose the number of columns of a table that I create, it gives me a single column, and even until this column after being filled with its properties, the field registration does not take.
except before I didn't have this problem
I don't know what was the problem, but after deleting the installation files and reinstalling, the problem disappeared
We've got a web application that takes a uniquely generated workshop ID and calls a procedure (using php) and this procedure inserts it into a sql server table. This table has a clustered index on column workshopID and is set to unique.
This morning we had a user report that he got the following error code on his page:
Cannot insert duplicate key row in object 'dbo.table with unique
index 'ClusteredIndex-Wrkshp'. The duplicate key value is (Z9C1Am)
Obviously this suggests that I'm trying to insert Z9C1Am into the table and that value already exists---HOWEVER, when we do a simple lookup on that value, this value did not exist so I took the same stored procedure that the website code calls and used it to inserted Z9C1Am (using SSMS) into the table without any problem.
I can also get onto this application without any problems with this error; however, this same user called again and said he had the same issue (on the same computer) in another session. This time it had a different wordshopID in the error, but once again, this did not exist in the database.
I don't believe this has anything to do with inserting a duplicate key, rather, it is a phantom error.
Any suggestions on how to confirm this and how to track the actual error?
My gut reaction is this must be a browser related problem; however, all the code that interacts with the sql database is server side so this theory doesn't make much sense.
Thanks for the responses guys!
Greg's comment made me start looking harder at my dependencies and I have a join statement inside of my insert statement. The table I was joining to was supposed to contain unique values and approx. 25,000 of them are; however I had one set of duplicates causing the error.
I seem to be having an issue when updating records on a specific table.
For reference here is an example of the query that throws an error:
UPDATE `dbname`.`tblname` SET `CustomerID` = '543' WHERE `tblname`.`Issue_ID` = 440
I am able to insert, delete and query rows, as well as update other columns however whenever trying to update the CustomerID field (int, non-null) it throws an error saying:
#1054 - Unknown column 'Revision' in 'field list'
I have all rights to both the database and table however while trying to update the CustomerID column on any rows, ever when Revision isn't even in the query I get the same error.
I looked around a great deal into the issue using a regex in my php code to remove all non-printable characters however even when running the query from phpMyAdmin the same error is thrown.
If anyone has insight into this error it would be greatly appreciated.
Table description:
You may possibly encounter this if you have an update trigger firing off which is referencing a column that does not exist. May be the offending trigger is not even trying to read/write to this table! As such, that column may not exist where it is trying to reference it. Further, you could kick off a cascade of such triggers, and have this buried more than one layer deep.
To show triggers:
http://dev.mysql.com/doc/refman/5.7/en/show-triggers.html
To modify them:
http://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html
This is my first post, and there is a similar post here: phpMyAdmin doesn't show added columns - Stack Overflow
But since no one has answered, I will ask here and provide more details in hoping to resolve this issue. I have a table in my database that I needed to be able to add additional columns to. I've done this using the following query:
$sql = "ALTER TABLE tablename ADD columnname INT(11)"; //Run the query....
This worked perfect on day one, however on day two when I tried to add an additional column via this php script, it appears to work from the phpMyAdmin Structure view. The column is in there with the correct columnname and datatype. However when I switch to the Browse view, there is no Column Name, just blank columns filled with "null" values. But, if you click on an individual row, it shows the correct column name, and a value (if one exists for that row).
I've tried running Analyze Table, as I read somewhere that that would update the Schema. However, I haven't had any success with that fixing it. I'd prefer to not have to delete the table and restart, especially if I run into this issue again. As this is my first post, I've tried to format everything correctly, but please forgive me if I didn't. Also, I can grab screenshots if anyone is having issues understanding my question.
if you can, restart mysql, it should flush everything, including mysql caches phpmyadmin may be using.
I'm using an INSERT ON DUPLICATE KEY statement for my website. It's for creating news items, so I figured I could use the same MySQL command for both creating and updating news items.
However, when I use the following:
INSERT INTO table (id,title,content) VALUES(NULL,"Test","Test");
Instead of creating a new auto increment value it throws an error. However, the command works on my main development server. But not on my laptop. Both versions of MySQL are the same, the only difference being MySQL was installed manually on my server, and with WAMP on my laptop.
Are there any MySQL Variables that could be causing this?
I would suggest using INSERT INTO table (title,content) VALUES("Test","Test");
This will create a new row in the table with a new incremented ID.
Managed to solve it as best as I can.
I checked my code and found that when I inserted the empty POST'd ID was wrapping it in quotations. I've now changed it so that it puts NULL without quotations. So my query should now look like:
INSERT INTO table (id,title,content) VALUES(NULL,"test","Test")
ON DUPLICATE KEY UPDATE title=VALUES(title), content=VALUES(content);
That now works.
I think you should make query like this,
INSERT INTO table (title,content) VALUES("Test","Test");
If it still doesn't work then check if id column is set as auto-increment or not.