In the discussion on IDs in Data Explorer, ganncamp observed that selecting a foreign key (FK) ID in a table displays a linked name, whereas selecting a primary key (PK) ID only shows a number. JammyDodger suggested aliasing the id column to post_id to achieve the desired linking behavior for PKs.
JammyDodger also shared another trick for creating interactive user lists by concatenating the users.id and users.username_lower columns to form an admin URL. Additionally, tshenry mentioned that there are more tricks to beautify results in the Discourse UI and shared a test query file with examples.
I’ve noticed that if I select an FK ID in a table, I get a beautifully presented, linked name. Whereas if I select a PK ID in a table, I just get a number.
For example, when I select the (PK) id field from Posts:
I’ve been wondering if there’s some sleight-of-hand I can do to get this lovely linking behavior from PKs. Or do I always need to throw in an extra table & select from it when I want linking?