© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
3 replies
Night_Nurse

Creation of FTS column which combines data from two different tables inside VIEW

I want to create fts column for the full text search combining the data from two different tables which have relationship between:

create table countries {
id: uuid();
name: string;
}
create table countries {
id: uuid();
name: string;
}


create table cities {
id: uuid();
name: string;
counry_id: uuid references countries(id)
}
create table cities {
id: uuid();
name: string;
counry_id: uuid references countries(id)
}



CREATE VIEW cities_fts
SELECT 
cities.id as city_id,
cities.country_id as county_id, to_tsvector('english', concat_ws(' ', cities.name, country.name )) AS fts
FROM countries, cities
WHERE (cities.country_id = countries.id);

CREATE VIEW cities_fts
SELECT 
cities.id as city_id,
cities.country_id as county_id, to_tsvector('english', concat_ws(' ', cities.name, country.name )) AS fts
FROM countries, cities
WHERE (cities.country_id = countries.id);


If I query
.from('custom_view').select(*, counties(*))
.from('custom_view').select(*, counties(*))
I will get a response with country object included.
But if I query
.from('custom_view').select(*, cities(*))
.from('custom_view').select(*, cities(*))
I'll get an error about no relationship between
custom_view
custom_view
view and
cities
cities


This is because I create a view with
cities.id
cities.id
which is just a id and not a foreign key and
cities.county_id
cities.county_id
which is a foreign key, right?

How can I go around it?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

FTS Generated Column using data from multiple tables
SupabaseSSupabase / help-and-questions
3y ago
How to select from two tables?
SupabaseSSupabase / help-and-questions
4y ago
Webhook data from multiple tables
SupabaseSSupabase / help-and-questions
3y ago
Cant view or read from my tables
SupabaseSSupabase / help-and-questions
2mo ago