News for hackers. Stuff that matters.
Re:SQL Design Patterns by sgarland on Saturday August 30, 2025 @08:28PM (#45079245)
Parent made it sound - to me - that you put an input in and hope for the best. If you understand the operators, you can quite confidently predict an output given an input.
Re:SQL Design Patterns by halfcat on Saturday August 30, 2025 @09:12PM (#45079453)
> If you understand the operators

That’s the point. In an imperative language if you don’t yet understand (or make a typo, or whatever), you can just print/console.log and find out.

I’ve seen junior devs, data analysts, and LLMs spin their wheels trying to figure out why adding a join isn’t producing the output they want. I don’t think they would figure it out using SQL alone if you gave them a month.

Re:SQL Design Patterns by SkiFire13 on Sunday August 31, 2025 @03:44AM (#45081238)
The equivalent of `print`/`console.log` in SQL would be using subqueries/CTE and run them to see the intermediate result (just like `print`/`console.log` show you intermediate results of the executions in an imperative language).
Re:SQL Design Patterns by sgarland on Sunday August 31, 2025 @10:20AM (#45083340)
Then you back off, and go back to first principles. Create the minimum example of the problem, and as a sibling comment mentioned, break it down to its constituent parts and observe what happens in each.