Flexibility in ordering the
SELECT clause and the table expression
SELECTis always the first keyword. It must be expressed before the table expression. We’ve shown in a previous article that this is quite confusing for many SQL users. While the existing syntax should continue to exist, it would be good to be able to inverse the
SELECTclause and the table expression.
Remember, the table expression contains
FROM table WHERE predicate GROUP BY columns SELECT columns
GROUP BYclauses, as well as vendor-specific
CONNECT BYclauses and others:
<query specification> ::= SELECT [ <set quantifier> ] <select list> <table expression>This language feature is already available in LINQ, by the way.
Implicit KEY JOINsThis feature is also available in jOOQ, using the
ON KEYclause. Note that Sybase also supports
from post key join user key join comment select *
Named projectionsThis is one of the features we really wish that the SQL language had. However, we wouldn’t count on specifying projections in a dedicated syntax. We had rather use an extension to the table expression syntax, allowing for a table to produce “side-tables” as such:
In the above example,
from dbo.users with projection as ( firstName, lastName, phoneNumber, email ) select projection.*
projectionis really nothing else than another table expression that is derived from the
userstable. From a SQL syntax semantics, this would be extremely powerful, because such projections would inherit all syntactic features of a regular table. We’ve blogged about this before, when we called that feature “common column expressions”.
2 thoughts on “A Better Query Language than SQL”
Is BQL dead?