I now have a table of contacts and a table of companies (I'm using the retool database). In the table of companies, there is a column with a foreign key to the contacts table. Now in the companies table I only see the id numbers of the contacts. But i would like to see the name. How can i get that done?
Some help would really be appreciated!
Thanks in advance,
Ps. I'm still learning all of this...
so i did some digging and some chatting .
the sql code below is for the readRow Query
SELECT customers.id, customers.name, customers.street, customers.zip, customers.city, customers.country, contacts.name AS contact_name
FROM "customers example" AS customers
LEFT JOIN "contact example" AS contacts ON customers.contact_person = contacts.id;
In this query, the "contact_person" column of the "customers example" table is compared to the "id" column of the "contact example" table to retrieve the name of the corresponding contact person. This name is then renamed to "contact_name" using the "AS" operator in the SELECT statement.
With this query, you will get the name of the contact person instead of just the ID number.
I hope this helps someone else in the future!