TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: CoffeeScript for SQL?

1 点作者 Johngibb大约 13 年前
Most of us spend a decent part of our days writing relational database queries in a language that was designed in the 1970s. While the actual clauses of the query are very expressive, I could think of a lot of ways to clean it up.<p>One of my biggest pain points is that a CTE can't be used for more than one select statement. Basically a temporary view. Why can't I do:<p><pre><code> var @users = ( select * from dbo.Users where isActive = 1 ); select * from @users; select * from Projects p where exists ( select * from @users where userId = p.userId ); </code></pre> Or hell, even:<p>create view #Users as select * from dbo.Users where isActive = 1;<p>The compilation would be a trivial substition of the initial variable as subqueries:<p>select * from ( select * from dbo.Users where isActive = 1 ) x;<p>select * from Projects p where exists ( select * from ( select * from dbo.Users where isActive = 1 ) x where userId = p.userId );<p>I know that there are some very good ORMs that can sometimes be a solution. But sometimes you need SQL.<p>Why hasn't anyone developed a higher level language that compiles down? We've done it with LESS, SASS, CoffeeScript, haml.

2 条评论

fagatini大约 13 年前
Seriously? I don't see how SQL could be made more simple. There are like what... a dozen keywords?
clarkevans大约 13 年前
You might try HTSQL, it is a navigational query language for relational databases.