Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
nice-try-fletch
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
3 ms
·
1.
▲
by
nice-try-fletch
3y ago
_SELECT 1 means "select the first column"_ In SQL Server at least, no, it literally means select the integer 1. In the ORDER BY clause, it does mean to order by ordinal position, but that's not a great thing to glorify, since
2.
▲
by
nice-try-fletch
3y ago
You could. But `SELECT 1` is a very common pattern in SQL Server, intended exactly to declare intent to the reader that "this subquery doesn't return any real data" - in the event the `EXISTS` that surrounds it isn't eno
3.
▲
by
nice-try-fletch
3y ago
Well, SQL Server (seemingly the author's area of expertise) doesn't have a lateral join. You can simulate this to some extent using CROSS APPLY, but that wouldn't really be any better than EXISTS in the case like the example,
4.
▲
by
nice-try-fletch
3y ago
Looks like the Plan Explorer extension for Azure Data Studio.
5.
▲
by
nice-try-fletch
3y ago
I don't think the one category is a mistake, merely a simplification. Why introduce another table that complicates the example and adds nothing? The article doesn't seem to be about "here's the absolute perfect design fo
6.
▲
by
nice-try-fletch
3y ago
It's an arbitrary but common one used in SQL Server. If the example used 128, you'd ask "why 128?" If it was 64, 50, 100, or any other number, you'd still ask. What is the right number? String lengths should come fr
7.
▲
by
nice-try-fletch
3y ago
But the example is exactly the type of query where I often see DISTINCT used where it shouldn't: they just want to know the customer with at least one order or the author who wrote at least one book or the user who upvoted at least one