3 ms·
I do something similar: select site.name , site.plan , site.status , domain.domain , subscription.updated_at
by aidos 14y ago
I do something similar:
select
site.name
, site.plan
, site.status
, domain.domain
, subscription.updated_at
from
subscription
inner join site on subscription.site_id = site.id
inner join domain on domain.site_id = site.id
where
subscription.status = 'inactive'
and subscription.plan = 'pro'
and domain.created_at <= '2012-04-01'
order by
subscription.updated_at desc
When I was writing a lot of sql I found it a lot easier to work with (when you're commenting things out a lot during development for example). Also, I'm a geek, so I like stuff lined up.
I understand the arguments for putting commas at the end of the line. For example, Google say in their style guide that when reading, having the comma at the end alerts the reader to the continuation on the next line. In languages that allow trailing commas (Python, php, C# etc) that's what I do. I put them at the front otherwise.
It's certainly not worth an overreaction though. Having commas on either end of the line isn't going to kill anyone. I've written 1000s of lines of sql in both styles and the world hasn't imploded yet.
As always, be consistent with the surrounding code - that's more important than any other rules (especially ones with a purely subjective basis).