RPC that return result of joining to tables
I got two tables. one for products and one for stores and want to return a list of brands for the city id passed as a parameter, and also only those stores that has a is_listed value of true.
But I get an error saying
What does this error mean in my case?
here is my code:
But I get an error saying
Failed to run sql query: column reference "city_id" is ambiguousWhat does this error mean in my case?
here is my code:
create or replace function get_list_of_brands(city_id int)
returns void
as
$func$
Select brand from
(SELECT
brand, is_listed
from (
SELECT DISTINCT
product_table.brand as brand, stores_v3.store_id as storeID, stores_v3.city as city, stores_v3.is_listed as is_listed
FROM product_table
LEFT JOIN stores_v3 ON stores_v3.store_id = product_table.store_id
LEFT JOIN city_table ON stores_v3.city_id = city_table.city_id where city_table.city_id = city_id
ORDER BY product_table.brand
) as TableBrand
where is_listed = true
) as Brand_AllStores
$func$
language sql;