Hacker News new | past | comments | ask | show | jobs | submit login

I was hoping to see some examples of more complex WHERE clauses. They can get a little messy when you start mixing ANDs and ORs at different levels of nesting.

Also, why are

  wine_tags as (
    SELECT DISTINCT
      unnest(tags) as tag,
      wine_id
    FROM 
      app_rating
    GROUP BY 
      wine_id, tags),

  wine_detail as (
    SELECT
      app_wine.name as name,
      app_wine.id,
      app_winery.name as winery
    FROM
      app_wine,
      app_winery
    WHERE app_wine.winery_id = app_winery.id
   ) 
handling closing parentheses differently? This affects how you organize nested parentheses.



My rule is that if I'm mixing ANDs and ORs in a WHERE, I use parentheses and extra indentation.

Not everyone knows that AND binds more tightly. Nor should they have to.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: