TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Poll: JOIN FOREIGN

2 pointsby JoelJacobsonover 3 years ago
This is a follow-up to &quot;SQL language proposal: JOIN FOREIGN&quot; [1] [2].<p>Thanks to the comments from HN and Github users, new syntax alternatives have been added to the proposal. Please vote on the syntax you prefer, feel free to leave any other comments, including other syntax ideas.<p>Note: Choice 1,2,3 use foreign key names in the syntax, while Choice 4 uses foreign key <i>column</i> names, similar to JOIN USING.<p>For details, see the &quot;Alternative syntax&quot; section of the Gist [2].<p>1) JOIN FOREIGN fk_alias.fk_name (original proposal)<p><pre><code> SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM films f JOIN FOREIGN f.films_did_fkey d SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM distributors d JOIN films f FOREIGN films_did_fkey REF d </code></pre> 2) JOIN table FOREIGN fk_alias.fk_name REF pk_alias<p><pre><code> SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM films f JOIN distributors d FOREIGN f.films_did_fkey REF d SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM distributors d JOIN films f FOREIGN f.films_did_fkey REF d </code></pre> 3) JOIN table FOREIGN fk_name [ FROM | TO ] alias<p><pre><code> SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM films f JOIN distributors d FOREIGN films_did_fkey FROM f SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM distributors d JOIN films f FOREIGN films_did_fkey TO d </code></pre> 4) JOIN table FOREIGN (fk_col, ...) [ FROM | TO ] alias<p><pre><code> SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM films f JOIN distributors d FOREIGN (did) FROM f SELECT f.title, f.did, d.name, f.date_prod, f.kind FROM distributors d JOIN films f FOREIGN (did) TO d </code></pre> [1]: https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29739147<p>[2]: https:&#x2F;&#x2F;gist.github.com&#x2F;joelonsql&#x2F;15b50b65ec343dce94db6249cfea8aaa#sql-language-proposal-join-foreign

1 comment

apa123over 3 years ago
Foreign key join to the moon!