4 ms·
Reading SQL is like reading German, where the last word in a long sentence determines the meaning of the entire sentence. An SQL statement starts with "select
by Viliam1234 7y ago
Reading SQL is like reading German, where the last word in a long sentence determines the meaning of the entire sentence.
An SQL statement starts with "select ABC.XYZ", but you have no idea what it means, because only one screen later it is written that "ABC" is actually an alias for "T_ACCOUNT_BUSINESS_CREDITS" or something. The logical order would be "from ... where ... select ...".
Imagine a programming language designed like SQL. It would look approximately like this:
function foo(a) {
return s;
b = join(a);
s = concatenate("[", b, "]");
by the way, a is list of strings, b is string, s is string;
also, function "join" is imported from "lists", and "concatenate" is imported from "string" module;
actually, don't return the result, just tell me how many characters it would have;
}
- karmakaze 7y agoI don't know why people think this. After much thought, it's because they read chronologically which isn't how SQL works. It doesn't 'execute' in the written sequence. The entire statement is a logical one like a mathematical equation. You wouldn't think that the meaning of (a + b) * (c + d) implies that (a + b) has to be done first. Maybe in some computer languages it may like early C compilers. Given that: "select ABC.XYZ" is perfectly well formed, it's like a forward reference declaration where ABC is the alias for a table-like thing and XYZ is the alias for the column-like thing. I mostly read my SQL inside-out, starting with uncorrelated subqueries. Another pet peeve: using the keyword INNER or OUTER is just noise.
- Izkata 7y ago> Imagine a programming language designed like SQL. Okay: const { ABC, XYZ } = source_table.get(id = 5); Oh, wait...