Skip to main content

Command Palette

Search for a command to run...

Filament PHP Table: field list is ambiguous

Updated
1 min read
G

I am a self-taught developer currently in Salt Lake City. Currently, work in Laravel but have experience in plain PHP, PERL, and CakePHP.

Entrepreneurial VP of tech and CTO with a strong grasp of both the business and engineering. PHP developer for 10 years with experience in CakePHP and Laravel

When adding a search to a Filament table, you might come across an error like this:

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'email' in field list is ambiguous.

The issue arises from joining two or more tables with the same column name as the one you are attempting to search. The fix is to pass the column and table name into the ->searchable() function:

// Example Join
Users::query()
->join('contacts', 'contacts.user_id', '=', 'users.id');

// TextColumn is searchable on contacts when both tables have the email column
Tables\Columns\TextColumn::make('email')->searchable(['contacts.email'])->sortable(),