getting data from two tables that are not directly...
# javascript
v
getting data from two tables that are not directly linked by a foreign key
Hello, I have two tables
messages
and
profiles
. Both have a foreign key
user_id
refering to the id of the
users
table. I want to return all messages with the username of the user that has written the message. In SQL, I would do something like this:
Copy code
SQL
SELECT messages.text, profiles.username
FROM messages, profiles
WHERE messages.user_id = profiles.user_id
How do I use the supabase client to get something equivalent? I would like a response data that look like this:
Copy code
js
[{text: "hi mom", username: "Pablo"}, {text: "hello world", username: "Edouard"}]