3 ms·
Doesn't this just move the problem to when you add a longer statement like "INNER JOIN"? Then the entire SQL statement becomes the diff?
by lgas 4y ago
Doesn't this just move the problem to when you add a longer statement like "INNER JOIN"? Then the entire SQL statement becomes the diff?
- jaza 4y agoAgreed. My standard is to pad with 12 spaces, eg: SELECT foo FROM bar Which allows room for everything I commonly use, including INNER JOIN.
- giraffe_lady 4y agoSometimes yes. I don't think there are any perfect solutions and I won't pretend this one is. But usually I find those change less frequently than columns and where clauses, and if you write them out and declare them explicitly you rarely have to move the whole query over. It does happen though.
- ttfkam 4y agoI tend to write SELECT a.foo , b.bar , array_agg(z.gumball) gumballs FROM zoo z INNER JOIN alpha a ON (z.z_id = a.z_id) LEFT JOIN baker b ON (a.a_id = b.a_id) WHERE z.last_modified > '2023-01-01' AND a.is_active GROUP BY 1, 2 ORDER BY 2, 1 LIMIT 100 ; Left side highlights the operations. Commas and "AND" delimit parts of each directive. The semicolon lines up on the left side to help visualize the end of each statement in a long chain of commands, especially DDL. I also tend to capitalize the SQL keywords and leave the identifiers lower case.