Next.js Discord

Discord Forum

Filter on concatenation of columns

Unanswered
Bigheaded ant posted this in #help-forum
Open in Discord
Bigheaded antOP
I need to do something like the following:

Given the tables:
- company_users, which is a join table between companies and user
- users, which contains a first_name and last_name column
Select all users whose first name, last name, or first and last name combined match the query text passed in.

const res = supabaseClient
  .from('company_users')
  .select('users(*)')
  .ilike('CONCAT(users(first_name), users(last_name))', `%${queryText}%`);

but throwing a CONCAT in the query like that won't work because it thinks it's a column name. Is this doable without creating a view or a searchable column like is discussed here: https://supabase.com/docs/guides/database/full-text-search#searchable-columns?

0 Replies