in this tutorial, we’ll learn how to fix “UNKNOWN COLUMN IN ‘FIELD LIST'”. Sometimes, We’re are getting errors after each insert or update to the MySQL table.
The message is “Unknown column ‘column-name’ in ‘field list'” while this column was existing in this table.
The most common causes of the error “MySQL: Unknown column in field list” are listed in this tutorial.
The MySQL unknown column in field list error happens when you put a column name in your SQL script that can’t be found by MySQL.
I have created an employee
table and inserted data as below:
The following error message is thrown by MySQL when you attempt to insert data into a column that doesn’t exist in the table:
Let’s create a SQL to insert data into the non-existence column:
INSERT INTO employees(emp_name) VALUES ('Tim');
The error below is because there’s no emp_name
column in the employees table.
Sometimes, We didn’t use quotes for the string values and also throw the same errors.
INSERT INTO employees(emp_name) VALUES (Tim);
The error:
-- ERROR 1054 (42S22): Unknown column 'Tim' in 'field list'
The value Tim must be wrapped in quotations (” or “”). Your attempt to put values into the target column from a different column will be misinterpreted by MySQL.
The same error will throw if calling a variable without the @
symbol.
SET @name="Tim"; SELECT name;
The Error message:
-- ERROR 1054 (42S22): Unknown column 'name' in 'field list'
Sometimes, we have defined triggers into MySQL that have columns that do not exist, t ll trigger when any record insert into MySQL.
create trigger insert_on_emp after insert on employee for each row begin insert into department (name, dept) values (new.name, 'devops'); end## delimiter ;
To solve the error I will need either rewrite the trigger and remove dept
column from the insert command or alter table ‘department’ and add column ‘dept’.
This tutorial helps integrate a PHP SDK with Laravel. We'll install aws-php-sdk into laravel application and access all aws services… Read More
in this quick PHP tutorial, We'll discuss php_eol with examples. PHP_EOL is a predefined constant in PHP and represents an… Read More
This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More
We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More
in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More
I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More