GORM Error: 'Unknown column 'stock_group_relation.code' in 'on clause'' - Troubleshooting and Solution
This error message indicates that there's an attempt to join two tables on a column ('code') that doesn't exist in the 'stock_group_relation' table.
To resolve this, follow these steps:
-
Inspect the SQL Query: Check the SQL query generated by your ORM (GORM in this case) or the manually written query. Verify that the column names and table names are spelled correctly.
-
Examine the Database Schema: Confirm that the 'code' column actually exists in the 'stock_group_relation' table. You can do this using your database management tool or by running a query like 'DESCRIBE stock_group_relation'.
-
Add the Missing Column: If the column is absent, use an 'ALTER TABLE' statement to add it to the 'stock_group_relation' table. For example:
ALTER TABLE stock_group_relation ADD code VARCHAR(255);
Once the 'code' column is added, you should be able to join the tables without encountering this error.
原文地址: https://www.cveoy.top/t/topic/mQbu 著作权归作者所有。请勿转载和采集!