Newbie: How do I display the text value in my table and not the (foreign key) ID?

Hi All,

I have created a simple form to add data to my table.
This form has a drop down - which references a foreign key field in another query/table.
This works correctly. (I.e. I get friendly name in my drop down)

However - when I view the data that it has entered /saved - in table view. It displays the foreign key, and not the name.

This is simple I'm sure - but how do i display the friendly name in my table andf not the foreign key value?

See image below:

check to make sure that the column Sector is using the sector.id.label

Show please a query for your table. I think you should SELECT FROM table with companies and LEFT JOIN with table that contain sector names
something like this

SELECT t1.company,t2.secorName FROM t_companies AS t1
LEFT JOIN t_sectors AS t2 ON t1.sectorId=t2.id

thanks Scott.
I'm populating this table with: {{load_all_companies.data}}
Should I be using some other method?

Sorry - I know this is completely rudimentary - but I've spent a few hours experimenting and trying to find a solution from tutorial videos - to no avail.

I like the product, but I'm not a coder - so I'm struggling to find resources to pick this up from zero.....

thanks again, Neil

thanks Alk - is there a quick way to see the code?
Because I am simply using: {{load_all_companies.data}} in the table - and the query is selecting all data from my table (which indeed stores the values only - as foreign keys). So - should i be adding the left join in the query that the table is using?

Query load_all_companies:

select * from company
order BY company_name

thanks.

I got it, here we are:

SELECT company.company_name, company.sector_id, sectors.sector_name
FROM company
LEFT JOIN sectors
ON company.sector_id = sectors.id;

thanks.

1 Like