© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
1 reply
Leetz Eh?

Column 'name' in where clause is ambiguous

I have quite an extensive admin-panel with lots of columns and custom filters/queries.

This works fine for most options, but when I try to search for things (and sometimes with sorting but that's an issue for later), I get the error as mentioned in the title.

This is most likely caused by the fact that I have two tables with the column 'name': Patients and Practices, which makes SQL unsure about in what table to look for.

Part of the Laravel SQL error:
...
  AND (
    EXISTS (
      SELECT
        *
      FROM
        `patients`
      WHERE
        `examinations`.`patient_id` = `patients`.`id`
        AND `name` LIKE % sudw %
        AND `patients`.`deleted_at` IS NULL
    )
    OR EXISTS (
      SELECT
        *
      FROM
        `practices`
        INNER JOIN `patients` ON `patients`.`practice_id` = `practices`.`id`
      WHERE
        `patients`.`id` = `examinations`.`patient_id`
        AND `name` LIKE % sudw %
        AND `practices`.`deleted_at` IS NULL
        AND `patients`.`deleted_at` IS NULL
    )
...
...
  AND (
    EXISTS (
      SELECT
        *
      FROM
        `patients`
      WHERE
        `examinations`.`patient_id` = `patients`.`id`
        AND `name` LIKE % sudw %
        AND `patients`.`deleted_at` IS NULL
    )
    OR EXISTS (
      SELECT
        *
      FROM
        `practices`
        INNER JOIN `patients` ON `patients`.`practice_id` = `practices`.`id`
      WHERE
        `patients`.`id` = `examinations`.`patient_id`
        AND `name` LIKE % sudw %
        AND `practices`.`deleted_at` IS NULL
        AND `patients`.`deleted_at` IS NULL
    )
...


My columns are defined as followed:
    public static function patient(): TextColumn
    {
        return self::createColumn('patient.name', 'Patient')
            ->searchable()
            ->sortable();
    }

    public static function practice(): TextColumn
    {
        return self::createColumn('practice.name')
            ->searchable()
            ->sortable()
            ->limit(25);
    }

    protected static function createColumn(string $name, ?string $label = null, bool $defaultHidden = false): TextColumn
    {
        return TextColumn::make($name)
            ->label($label)
            ->toggleable(Admin::isGlobalAdmin(), $defaultHidden)
            ->alignCenter();
    }
    public static function patient(): TextColumn
    {
        return self::createColumn('patient.name', 'Patient')
            ->searchable()
            ->sortable();
    }

    public static function practice(): TextColumn
    {
        return self::createColumn('practice.name')
            ->searchable()
            ->sortable()
            ->limit(25);
    }

    protected static function createColumn(string $name, ?string $label = null, bool $defaultHidden = false): TextColumn
    {
        return TextColumn::make($name)
            ->label($label)
            ->toggleable(Admin::isGlobalAdmin(), $defaultHidden)
            ->alignCenter();
    }


What could be a good way to solve this problem? Thanks in advance!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Column 'id' in where clause is ambiguous in edit record page
FilamentFFilament / ❓┊help
2y ago
ambiguous column name: id
FilamentFFilament / ❓┊help
2y ago
RelationManager belongsToMany withPivot(['id']) returns Column 'id' in order clause is ambiguous
FilamentFFilament / ❓┊help
2y ago
Import Action - "unknown column '' in `where clause` "
FilamentFFilament / ❓┊help
16mo ago