Every now and then, I see folks lament the SQL syntax's peculiar disconnect between the lexical order of operations (SELECT .. FROM) the logical order of operations (FROM .. SELECT) Most recently here in a Youtube comment reply to a recent jOOQ/kotlin talk. Let's look at why jOOQ didn't fall into this trap of trying … Continue reading Changing SELECT .. FROM Into FROM .. SELECT Does Not “Fix” SQL
Tag: syntax
5 Ways to Better Understand SQL by Adding Optional Parentheses
It appears that our recent beginner SQL articles explaining SQL syntax were quite popular. These include: A Beginner’s Guide to the True Order of SQL Operations A Probably Incomplete, Comprehensive Guide to the Many Different Ways to JOIN Tables in SQL 10 Easy Steps to a Complete Understanding of SQL How SQL DISTINCT and ORDER … Continue reading 5 Ways to Better Understand SQL by Adding Optional Parentheses
It’s the Little Things: The PL/SQL NULL Statement, and why Every Language Should have One
Syntax is one of those topics. One of those emotional topics that lead to very very very important discussions. I personally like PL/SQL. It is extremely verbose, and precise. It forces you to adhere to a very strong and rigid type system, slowing you down, which is likely to help you avoid mistakes. There is … Continue reading It’s the Little Things: The PL/SQL NULL Statement, and why Every Language Should have One
Should I Put That Table Alias or Not?
Infrequent SQL developers often get confused about when to put parentheses and/or aliases on derived tables. There has been this recent Reddit discussion about the subject, where user Elmhurstlol was wondering why they needed to provide an alias to the derived table (the subselect with the UNION) in the following query: SELECT AVG(price) AS AVG_PRICE … Continue reading Should I Put That Table Alias or Not?
SQL Server Trick: Circumvent Missing ORDER BY Clause
SQL Server is known to have a very strict interpretation of the SQL standard. For instance, the following expressions or statements are not possible in SQL Server: -- Get arbitrarily numbered row_numbers SELECT ROW_NUMBER() OVER () -- Skip arbitrary rows SELECT a FROM (VALUES (1), (2), (3), (4)) t(a) OFFSET 3 ROWS Strictly speaking, that … Continue reading SQL Server Trick: Circumvent Missing ORDER BY Clause
Feature Request for the JLS: Auto-Rethrow
Java 7 has eased some pain in the area of exception handling when the new try-with-resources and multi-catch syntaxes were introduced. The latter is very interesting from a syntax perspective because it is the only place in Java where formal union types are allowed, similar to what Ceylon offers. Remember, a union type A | … Continue reading Feature Request for the JLS: Auto-Rethrow
Why PostgreSQL is so Awesome
Just recently, I've blogged about PostgreSQL 9.3 having been released, which is awesome enough as PostgreSQL finally supports materialised views and updatable views. I have then blogged about PostgreSQL's syntax being a mystery only exceeded by its power, as it allows for treating INSERT and UPDATE statements as table references, when used with the RETURNING … Continue reading Why PostgreSQL is so Awesome
Java, if this were a better world
Just a little dreaming about a better world, where some old blunders in the Java platform would've been corrected and some awesome missing features would've been implemented. Don't get me wrong. I think Java is awesome. But it still has some issues, like any other platform. Without any particular order, without claiming to be anything … Continue reading Java, if this were a better world
Syntax for calling “super” in Java 8 Defender methods
This is a very interesting discussion. How to reference default methods from implemented interfaces throughout the class / interface hierarchy? Situation: interface K { int m() default { return 88; } } interface J extends K { int m() default { return K.super.m(); } // ^^^^^^^^^^^^ How to express this? } Solution ideas: K.super.m() super.K.m() … Continue reading Syntax for calling “super” in Java 8 Defender methods
Let’s revise the SQL FROM clause
Intuitive SQL SQL is extremely simple and yet at times, tricky. Most SQL developers have an intuitive (as opposed to formal) understanding of how the language works, for two reasons: It is designed "intuitively", like a natural language. Maybe that keeps us from studying it more formally The formal language specification is not really freely … Continue reading Let’s revise the SQL FROM clause