6 ms·
I pretty much always start typing SQL queries with “SELECT *” because I know I’ll come back and figure that part out later. It’s similar to how I write Python
by baddox 7y ago
I pretty much always start typing SQL queries with “SELECT *” because I know I’ll come back and figure that part out later.
It’s similar to how I write Python list comprehensions. I almost always type “x for x in” from muscle memory, then get the collection part at the end correct, then go back and fix the beginning. My brain just won’t think in the other direction.
- talaketu 7y agoOh yeah I agree - the forward reference to attributes before the source is stated does feel backwards when writing the expression. Compare scala's for-comprehension that feels more natural: `for (x <- xs) yield x + 1;` Perhaps there's an argument that the shape of the result is defined up front, so it might be easier to comprehend the result if not the implementation.
- petepete 7y agoMe too. "select *", a couple of new lines, "limit 30;” now fill in the middle.
- mritchie712 7y agoI do this too, so the autocomplete in SeekWell automatically does this, check it out: https://www.loom.com/share/9c7979a163eb4513b3320e6e90c66079 https://www.loom.com/share/9c7979a163eb4513b3320e6e90c66079 If you type just a table name into an empty cell it will autocomplete with a full SELECT statement. e.g. if you typed "pubuser" and selected "public.users" it would autocomplete with: SELECT pu.* FROM public.users AS pu WHERE 1=1 It will even take a stab at aliasing the table for you. Disclaimer: I built this.