I have a MySQL EER diagram the I forward engineer into a database. I also use the forward engineer feature to generate insert statements for data automatically. After entering about 120 rows of data I forward engineered the database only for it to give an error:
ERROR: Error 1054: Unknown column 'XX' in 'field list'
SQL Code:
INSERT INTO `mydb`.`Person` (`Person_ID`, `SSN`, `FirstName`, `MiddleName`, `LastName`, `Gender`, `Race`, `MaritalStatus`, `Military`, `Note1`, `Note2`, `DOB`) VALUES (111, 'xxx-xx-xxxx', 'John', 'K', 'Smith', 'M', 'XX', 'XX', XX, 'Case_1', NULL, NULL)
I don't understand what the problem is; I'm using the forward engineer feature so none of the column names can be misspelled. Is this just a bug?
I'm using MySQL Workbench 8.0.31 if that helps. I know it isn't the latest version, but I downgraded because I encountered crashes while querying in the new version.
Update: J.D helpfully pointed out that the field didn't have quotes and from there I was able to find the problem. The Military field was a TinyInt and therefore wasn't being given quotation marks, but the data being inserted was a string; hence the error.
1 Answer 1
Well your issue is the following part in bold: 'XX', XX, 'Case_1' because it lacks single quotes. Not sure why a built-in auto-generation tool is doing that though. Maybe a bug in the old version of MySQL Workbench, that you're using.
-
Thanks, nice catch.SlowlySwift– SlowlySwift2023年06月18日 04:10:11 +00:00Commented Jun 18, 2023 at 4:10
-
Since there's hundreds of rows it's not really practical to fix each one by hand. Instead I'm gonna see if setting that field to null does the trick.SlowlySwift– SlowlySwift2023年06月18日 04:15:04 +00:00Commented Jun 18, 2023 at 4:15
-
I appreciate the helpSlowlySwift– SlowlySwift2023年06月18日 04:15:11 +00:00Commented Jun 18, 2023 at 4:15
-
@SlowlySwift No problem, glad to help!J.D.– J.D.2023年06月18日 04:56:51 +00:00Commented Jun 18, 2023 at 4:56
Explore related questions
See similar questions with these tags.