by jethkl · 2y ago · 0 comments
Step 1: use natural join. Life is great. Step 2: someone adds a `comment` field on table A. Life is great. Step 3: someone adds a `comment` field on table B. Ruh roh.
I'll use them in short-lived personal projects, but not on something where I'm collaborating with other people on software that evolves over several years.
CTE_A AS (SELECT ... comment as comment_a from A...),
CTE_B AS (SELECT ... comment as comment_b from B...)This is a very positive spin on "you have to manage column names very rigorously for this strategy to be sustainable".
Natural joins are naturally more implicit, and while SQL tends to be a little bit verbose, given the significance of data integrity and the dififculty of testing SQL, the trade-off goes very clearly towards being explicit.
No, records with the same join-column value are multiplied.