https://supabase.com/ logo
#help
Title
# help
m

Markido

01/28/2022, 2:02 PM
I have accounts with a user_id which is a foreign key to the users table. When i try to query accounts joined with users, it says no table users in the current schema. Do you guys know how i can fix it?
c

chipilov

01/28/2022, 2:04 PM
the users table is in the auth schema, so you probably need to use the fully qualified name - auth.users
m

Markido

01/28/2022, 2:05 PM
First error:
But then, if i change to auth.users in my join i get:
Im using the client, like so:
c

chipilov

01/28/2022, 2:09 PM
I don't use the js client for queries, so I might be wrong here, but I think the parameter in parenthesis needs to be the column name in the target table - in your case auth.users (id)
actually, that's probably wrong...
m

Markido

01/28/2022, 2:09 PM
The error does say that its the accounts.auth that doesn't exist tho
Some web ressources say its not possible to query the users table, and you should sync the desired data to a table in the public schema .
via triggers
c

chipilov

01/28/2022, 2:11 PM
you can definitely query it - you can either expose it through a view on the public schema OR you can implement the join in a view in a public schema.
I guess the question is can you do it ONLY via the JS client
...and I am afraid I don't know the answer to that question
m

Markido

01/28/2022, 2:11 PM
ohh right
i forgot about views actually haha
i will go ahead and do that - thanks
s

silentworks

01/28/2022, 4:42 PM
You can't query anything in the
auth
schema when not using the
service_key
(this should only be used server side).