{"id":2610,"date":"2024-12-31T20:23:15","date_gmt":"2024-12-31T20:23:15","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/solved-sqlstate42s22-column-not-found-1054-unknown-column-in-magento-2-admin-grid-massaction\/"},"modified":"2025-07-16T14:50:31","modified_gmt":"2025-07-16T09:20:31","slug":"sqlstate42s22-column-not-found-1054-unknown-column-in-magento-2-admin-grid-massaction","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/sqlstate42s22-column-not-found-1054-unknown-column-in-magento-2-admin-grid-massaction\/","title":{"rendered":"Solved: SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column in Magento 2 Admin Grid MassAction"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em><strong>SQLSTATE[42S22]: Column not found: 1054 Unknown column in Magento 2\u00a0<\/strong><\/em>is one of the most common errors that is displayed when a certain column is not found in the database. If you are a\u00a0Magento 2\u00a0store owner getting this error during mass action in the admin grid, then this blog post is for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Many Magento 2 store admins complained about the mass action functionality not working properly in the backend grid. The following error is displayed in Magento 2 while performing bulk actions from the backend. The admin panel displays the following error:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><em>.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column \u201d in \u2018where clause\u2019<\/em><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I have come up with a working solution to the SQLSTATE[42S22] error in Magento 2 admin panel, which occurs while performing bulk actions. You can follow the steps provided in this blog post to solve it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s begin!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Solve SQLSTATE[42S22] Error in Magento 2 Admin Grid Mass Action?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The mentioned error is displayed while performing bulk actions in Magento 2 admin grid because the query does not find any primary key for the requested data in the store\u2019s database. Therefore, the admin needs to define the&nbsp;<strong>$_idFieldName<\/strong>&nbsp;in the collection.php file in the backend first to set the primary key for the requested database. You can follow the below-mentioned steps to do that:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 1:&nbsp;<\/strong>Open the&nbsp;<strong>Collection.php&nbsp;<\/strong>file of the respective database. For example: Go to&nbsp;<strong><strong>app\\code\\Vendor\\Example\\Model\\ResourceModel\\ExampleResourceClass\\<\/strong>&nbsp;<\/strong>directory and open the&nbsp;<strong>Collection.php&nbsp;<\/strong>file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Step 2:&nbsp;<\/strong>Now define the&nbsp;<strong>$_idFieldName&nbsp;<\/strong>variable in the file with the column name of the primary key as the value. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>protected $_idFieldName = 'department_id';<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it! This is how you can solve the SQLSTATE[42S22] error in Magento 2 for performing mass action in the admin panel. Likewise&nbsp;solve SQLSTATE[42S22]: Column not found: 1054 Unknown column in Magento 2&nbsp;admin grid massaction, it is one of the most common errors that is displayed when a certain column is not found in the database.<br><br>If you still have any doubts or queries regarding the provided solution, feel free to comment. I will be happy to help you! After done with this you can also learn to&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/add-image-thumbnail-column-in-magento-2-admin-ui-grid\/\">add image thumbnail column in Magento 2 admin UI grid<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, do not forget to share this Magento 2 solution with your developer friends via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks for reading.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Also Read:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/meetanshi.com\/blog\/magento-2-backend-not-working-solution\/\" target=\"_blank\" rel=\"noreferrer noopener\">Solved: Magento 2 Backend Not Working<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/meetanshi.com\/blog\/debug-sqlstate42s22-column-not-found-1054-unknown-column-in-where-clause-in-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">Debug: SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column in \u2018where clause\u2019 in Magento 2<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/meetanshi.com\/blog\/solved-argument-passed-must-be-array-null-given-in-magento-2-admin-grid\/\" target=\"_blank\" rel=\"noreferrer noopener\">Solved: Argument Passed Must Be Array, Null Given Error in Magento 2 Admin Grid<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>SQLSTATE[42S22]: Column not found: 1054 Unknown column in Magento 2\u00a0is one of the most common errors that is displayed when a certain column is not&#8230;<\/p>\n","protected":false},"author":38,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2610","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2610","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/38"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2610"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2610\/revisions"}],"predecessor-version":[{"id":17945,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2610\/revisions\/17945"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}