Mysql

MySQL ERROR: UNKNOWN COLUMN IN ‘FIELD LIST’

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.

unknown column in field list error?

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:

Option 1: The column name is not found

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.

Option 2: Column value is not wrapped with Quotes

Sometimes, We didn’t use quotes for the string values and also throw the same errors.

Related Post

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.

Option 3: calling a variable without the @ symbol

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'

Option 4: MySQL Trigger issue

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’.

Recent Posts

Configure and Retrieve S3 Information Using Laravel PHP-AWS-SDK

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

3 months ago

What is the Purpose of php_eol in PHP?

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

9 months ago

Laravel Table Relationship Methods With Example

This Laravel tutorial helps to understand table Relationships using Elequonte ORM. We'll explore laravel table Relationships usage and best practices… Read More

9 months ago

Exploring the Power of Laravel Eloquent Join?

We'll explore different join methods of Laravel eloquent with examples. The join helps to fetch the data from multiple database… Read More

9 months ago

Quick and Easy Installation of Laravel Valet

in this Laravel tutorial, We'll explore valet, which is a development environment for macOS minimalists. It's a lightweight Laravel development… Read More

10 months ago

What is Laravel Soft Delete and How Does it Work?

I'll go through how to use soft delete in Laravel 10 in this post. The soft deletes are a method… Read More

10 months ago

Categories