Re: [sqlite] AS being optional
Dominick, On Fri, Aug 12, 2016 at 9:24 AM, Dominique Deviennewrote: > On Fri, Aug 12, 2016 at 2:42 PM, Keith Medcalf wrote: > >> [...] The main problem with the JOIN/ON syntax is that to a casual reading >> order is implied > > > No idea what you mean here :) > > >> ([...] ream of brackets [...]). >> > > Nor what this has to do with JOIN/ON. Get off the anti-MS soapbox Keith ;) For the "average Joe" the JOIN/ON" syntax is weird. So I have no idea why MS does it this way, since that's their target audience. ;-) > > >> TO me it is much simpler to understand: >> > > I guess we agree to disagree on this one. To each his own. And both forms > are valid of course. --DD And if you need to filter results, you don't have a choice, but use WHERE... Thank you. > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
On Fri, Aug 12, 2016 at 2:42 PM, Keith Medcalfwrote: > [...] The main problem with the JOIN/ON syntax is that to a casual reading > order is implied No idea what you mean here :) > ([...] ream of brackets [...]). > Nor what this has to do with JOIN/ON. Get off the anti-MS soapbox Keith ;) > TO me it is much simpler to understand: > I guess we agree to disagree on this one. To each his own. And both forms are valid of course. --DD ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
> I'm not a manager, and I do have a few "computer skills" (I think), and I > still find JOIN ON much more > readable than the FROM-comma + WHERE alternative. Helps me "thread" the > table join in my head much better. > Definitely helps me "grok" a statement faster, so not syntax sugar to me. > My $0.02. --DD The main problem with the JOIN/ON syntax is that to a casual reading order is implied (you can see this, for example, in the Microsoft products that litter generated SQL statements with ream upon ream of brackets perhaps in the hope of influencing a query optimizer, but more likely to ensure the result is as unreadable as possible). TO me it is much simpler to understand: SELECT FROM WHERE considering that JOIN which is mere sugar is (and ought) to be treated by replacing it with a "," and moving the conditions in the ON clause into the WHERE clause. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
> AFAIK, AS is necessary in UNION, at least on some RDBMS, to have the same > columns for all UNION'ed queries. > So in that sense, not strictly syntax sugar. And it's of course valuable > to > give good names to complex expressions. > A good name goes a long way to make "code" (of any sort) more readable and > obvious. In all cases where AS is used it can be replaced with nothing (removed). There is no distinct purpose for the string as that cannot be served by not having the string as (that is, search and replace all " as " with " ") and you will find that the only meaningful change is that the number of bytes in the statement is less ... JOIN however does have one (and only one) non-sugary use: it is about the only way to specify a join type other than a simple cross (or, where there is a where clause, an equijoin). Most vendors have removed all the various "not included in the spec" methods that used to be used to specify these types of operations. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
On Fri, Aug 12, 2016 at 2:55 AM, Keith Medcalfwrote: > > AS is optional as it was "syntactic sugar" added to SQL [...] > AFAIK, AS is necessary in UNION, at least on some RDBMS, to have the same columns for all UNION'ed queries. So in that sense, not strictly syntax sugar. And it's of course valuable to give good names to complex expressions. A good name goes a long way to make "code" (of any sort) more readable and obvious. Other syntactic sugar include the JOIN and ON syntax and keywords. I'm not a manager, and I do have a few "computer skills" (I think), and I still find JOIN ON much more readable than the FROM-comma + WHERE alternative. Helps me "thread" the table join in my head much better. Definitely helps me "grok" a statement faster, so not syntax sugar to me. My $0.02. --DD ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
AS is optional as it was "syntactic sugar" added to SQL so that Managers and others with no computer skills could read SQL too, just like the overriding design principle of COBOL wasto be "so simple and english like that even management could understand it". Having to end each statement with a period (.) was rejected because the period is already a reserved separator. Other syntactic sugar include the JOIN and ON syntax and keywords. If sugary coatings were made mandatory then perfectly legal SQL written between 1972 and 1995 would all have to be recoded with the sugary coating, thus breaking backward compatibility, and this was not a desired outcome of the standardization process. > -Original Message- > From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] > On Behalf Of Tim Streater > Sent: Thursday, 11 August, 2016 08:57 > To: sqlite-users@mailinglists.sqlite.org > Subject: [sqlite] AS being optional > > Is there a reason why AS is optional, such that: > > select a b, c from x > > is equivalent to: > > select a as b, c from x; > > I agree it couldn't be changed now, but luckily I spotted that I had > omitted a comma, before it was too late. > > -- > Cheers -- Tim > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
That's the ANSI / ISO standard for the SQL language. On Thu, Aug 11, 2016 at 10:02 AM, Richard Hippwrote: > On Thu, 11 Aug 2016 15:57 +0100, Tim Streater > wrote: > > Is there a reason why AS is optional > > Because that is what PostgreSQL does. (Also MySQL. Maybe others too.) > > -- > D. Richard Hipp > d...@sqlite.org > ___ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users > -- Klein bottle for rent -- inquire within. Maranatha! <>< John McKown ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Re: [sqlite] AS being optional
On Thu, 11 Aug 2016 15:57 +0100, Tim Streaterwrote: > Is there a reason why AS is optional Because that is what PostgreSQL does. (Also MySQL. Maybe others too.) -- D. Richard Hipp d...@sqlite.org ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users