Foreign key / name interchangeability

planned

Look up a familiar name instead of memorizing an id; SQLly follows the relationship for you.

Databases are fond of ids; people are usually fond of names. When you ask for values on a foreign-key id column, SQLly follows the foreign key and lets you search by name and insert the id. Put the cursor after WHERE CategoryID = and run Edit › Table Column Value Autocomplete: instead of the raw ids, the list shows the category names from Categories. Type part of a name to narrow it, and accepting one inserts the id with the name as a comment, such as CategoryID = 1 /* Beverages */. Typing an id still matches too.

How the name column is chosen

There's nothing to configure. SQLly reads the foreign key from the loaded data model and picks the referenced table's readable column, first match wins:

  1. A column called Name.
  2. The table's own name column: CategoryName on Categories (the singular of a plural table name counts), or Category_Name.
  3. The first text column whose name ends in Name, such as CompanyName.
  4. A column called Label, Display, Description, or Code.
  5. The first text column that isn't part of a key, and failing that the id itself.

Only = comparisons follow the key; after LIKE you get the column's own values. If the name lookup fails (for example, you can't read the referenced table), SQLly falls back to listing the raw ids. The list holds at most 100 rows, ordered by name.

SQLly
IntelliSense resolving a category name to a foreign-key idIntelliSense resolving a category name to a foreign-key id
Value autocomplete on WHERE CategoryID = listing category names from Categories; accepting one inserts its id.