DEV Community

Discussion on: What's Been Your Biggest "Why Didn't Someone Tell Me" Discovery?

Collapse
 
robinscodeongit profile image
robin

For me the most recent thing was CTE's (Common Table Expressions), best way to make SQL readable, instead of ugly encapsulation of every sub select you can give it nice names and easy structure.
here an example:

with my_cte as
(
select id, t.* from some.table t where
),
2nd_select as
(
select fk_id as id, t.* from awesome.table t
)
Select * from my_cte a
Inner join 2nd_select b on a.id = b.id