Unknown Column Error in Laravel - How to Fix
This error occurs when querying or inserting data with a column name that doesn't exist in the database table.
The Error
SQLSTATE[42S22]: Column not found: 1054 Unknown column
Common Causes
- 1 Column doesn't exist in table
- 2 Typo in column name
- 3 Migration not run after adding column
- 4 Model $fillable referencing non-existent column
- 5 Using wrong table alias in query
Solutions
Run pending migrations
php artisan migrate
Check which columns exist
php artisan tinker
>>> Schema::getColumnListing('posts')
Create migration to add missing column
php artisan make:migration add_status_to_posts_table --table=posts
// In migration up() method
$table->string('status')->default('draft');
Check for typos in your query
// Wrong
Post::where('staus', 'published')->get();
// Correct
Post::where('status', 'published')->get();
Need Help With Your Laravel Project?
I specialize in building custom Laravel applications, process automation, and SaaS development. Whether you need to eliminate repetitive tasks or build something from scratch, let's discuss your project.
About Hafiz
Senior Full Stack Developer. I build production software with Laravel, Filament, Vue, and AI integrations, and write about the real decisions behind shipping it.
Get in touch →Related Errors
SQLSTATE 42S02 Table Not Found in Laravel - Fix
SQLSTATE[42S02]: Base table or view not...
Migration Failed in Laravel - How to Debug and Fix
Migration table not found / Migration fa...
Laravel Database Connection Refused Error - Fix
SQLSTATE[HY000] [2002] Connection refuse...