Back to Error Center
SQLSTATE column not found
Error Message
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'posts.nonexistent' in 'field list'
Cause
The query references a column that doesn't exist in the table. The migration adding the column hasn't been run, or the column name is misspelled.
Solution
Create a new migration to add the missing column. Run php artisan migrate. Verify the column name in the model and query.
Code Example
Fix
// Create migration to add the missing column
Schema::table('posts', function (Blueprint $table) {
$table->string('subtitle')->nullable()->after('title');
});
// Run migration
php artisan migrate
Debugging Steps
- Check the database schema for the column
- Run php artisan migrate:status
- Verify column names in queries and models
- Check for recent migrations that may have dropped the column
Prevention
Always create migrations for schema changes. Never manually alter production databases. Use php artisan make:migration to scaffold changes.