- Feature Articles
- CodeSOD
-
Error'd
- Most Recent Articles
- It's About Time
- Scrollpocalypse
- Fast Quick
- 12345
- Said Different
- Ai Dios Mio
- Unrewarding
- Good Time
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The ongoing history of articles here suggests strongly that the company would never learn any useful lessons from that. They might be taught those lessons, but they sure as egcs is egcs wouldn't learn them.
Admin
If it's stupid and it works than it's still stupid but you don't care because you got it on the cheap.
Management 101.
Admin
There's no excuse for the second part and how the ID is checked in the array, but if the valid IDs are sparse, I'll excuse fetching the whole table thereof (a shame about the rest of the columns though).
Admin
As old content is retired it's hard-deleted from the database (rather than updating a "hide me" column), so valid IDs are sparse. Given the "many years ago" era there are probably a few dozen rightsides, max, so the kid following worst practices isn't going to get bitten by time or space constraints either.
Admin
10 bucks that they've now fireed all the expensive programmers and are using AI vibe coding instead.
Admin
Perhaps: Select Rightside where Not In a list of used so fars. But after 5 or 10 hits erase the list and start anew.
Admin
Ah. Maxim 43, which states in full: "If it's stupid and it works, it's still stupid and you're lucky."
Admin
Not sure if that works anywhere outside of SQL Server but it's a quick and dirty "select a random record" version I've used before
Admin
It doesn't look like it should work because I'd expect the
ORDER BYto require a column name, but it is documented as a way to select a random record (or several by changing toTOP nwherenis hew number of random rows you want) in the Microsoft transact-sql documentation.Admin
If I recall correctly the MySQL idiom was very similar to that, ORDER BY RAND(). Despite everybody doing it that way, it was not particularly good because the database server would calculate a random number for every matching row in the query. It was only fast because we all had tiny datasets.
Admin
ORDER BY accepts any expression, not just bare columns. Of course ORDER By clauses that use columns names can be assisted by an index while expression-based ordering doesn't typically use an index. MS SQL Server supports indexes on computed columns, so it's actually possible to use an index for expression-based ORDER BY terms.
Admin
Monkey paw: granted, entry-level positions now need 5 years of experience
Admin
Surely you could save computational power by computing a random value when the data is added to the table, and then do an ORDER BY on that column and grab the first item. Super fast!
Admin
a variation of the prng algorithm from the xkcd 221 standard