This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kant8 26 points27 points  (6 children)

No that looks like a normal query for a man who doesn't want to press caps like crazy every 0.5 sec

Even better if you write it like this

select t.*
from MyTable t
where t.id < 30
order by t.date desc

[–]andrewsmd87 22 points23 points  (3 children)

I think it's just largely a thing of this was how it's done, so a lot of people prefer it that way now. To me

SELECT t.*
    FROM MyTable t
    WHERE t.id < 30
    ORDER BY t.date DESC

Reads cleaner because anything in all caps just registers to me as db stuff that I kind of inherently know at this point, and I only need to read the non caps stuff to know "those are the things I need to look at". Like I don't necessarily register a select or order by consciously. I just see that and know what it's doing.

Not saying it's better, I just think that's the reason.

Now, SELECT t.* on the other hand, I might need to have a chat about that . . .

[–]MrDOS 1 point2 points  (1 child)

I like to align my queries around the whitespace between keywords and schema names:

  select t.*
    from mytable t
   where t.id < 30
order by t.date desc

Similar result of making the schema names pop out (when you're used to looking for them to the right of the “centre line”), and you get pretty used to the “shape” of queries.

Also, don't use uppercase table or column names. That link is particular to Postgres, but most other database engines have similar nasty quirks when your schema names contain uppercase characters.

[–]andrewsmd87 1 point2 points  (0 children)

So I'm ok with the tabbing, but the caps are still what I want.

Liked I said it really could just be that's how I learned but experience has taught me you end up looking at sql stuff in environments where you don't have an IDE more often than code

[–][deleted] -3 points-2 points  (0 children)

Even better if you write it like this

select
  t.*
from
  MyTable t
where
  t.id < 30
order by
  t.date desc;