March 31, 2026

No JavaScript, just checkmates

Chess in SQL

Database checkmates the web — fans cheer, purists grumble, and a ‘dragon’ loses a rook

TLDR: A developer built a playable chessboard using only SQL, proving databases can power more than storage. The crowd is split between cheering the creativity, debating JavaScript vs. “native” tools, and joking about a missing rook—while others ask for move checks and a link to start playing.

SQL just pulled a party trick: a fully playable chessboard built with nothing but database queries. The community reaction? Pure chaos and delight. The author jumps in to admit the chess board is a “trojan horse” to show SQL can model any grid — calendars, seating charts, even Conway’s Game of Life — and the crowd splits between applause and side‑eye.

On one side, fans are giddy: it renders a whole board, makes moves, even reenacts the legendary Opera Game. Folks are asking how to play and begging for features like move‑legality checks. On the other, the tool purists show up with folded arms. One commenter would “prefer a better (native?) language than JavaScript,” waving the security and open‑source flag while pledging loyalty to tools like DBeaver and DataGrip. Cue the JavaScript vs. Native skirmish in aisle three.

Meanwhile, comic relief arrives with a typo-turned-meme: someone swears “the dragon is missing a white rook,” which instantly becomes the thread’s mascot. Others joke about being checkmated by their own database at work. The strongest take? This isn’t about chess—it’s a flex that SQL can paint any grid you can dream up. The mild drama? Whether this is clever art or needless stunt coding. Either way, the comments are playing blitz.

Key Points

  • The article builds a functional chess board and playable moves using only SQL, with no JavaScript or frameworks.
  • A CTE generates all 64 squares via CROSS JOIN of ranks and files, LEFT JOINing the pieces onto the grid.
  • Rows are pivoted into an 8x8 grid using conditional aggregation (MAX(CASE ...)), COALESCE for empties, and ORDER BY rank DESC.
  • Moves and captures are performed with UPDATE, DELETE, and INSERT, with a file-to-number mapping (a=1…h=8).
  • The method is demonstrated by replaying Morphy’s 1858 Opera Game and is applicable to other grids like calendars or heatmaps.

Hottest takes

"The chess framing is a bit of a trojan horse, honestly." — upmostly
"I would prefer such a tool written in a better (native?) language than JavaScript." — landsman
"I think the dragon is missing a white rook" — FergusArgyll
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.