3 ms·
Why do SQL clauses need to be ordered, anyway? Is there anything that would be impossible to parse if the order was not defined?
by knodi123 7y ago
Why do SQL clauses need to be ordered, anyway? Is there anything that would be impossible to parse if the order was not defined?
- cm2187 7y agoTo be logical to beginners. So that autocomplete can help you (which it cannot if it doesn't know what tables you are querying).
- wodenokoto 7y agoBut the syntax is in the wrong order for autocomplete to help you. If from was first, autocomplete could help you with the names of columns, like RStudio does with dplyr: data_frame_name %>% select(column_name) Because you start by piping the data reference into your select function, RStudio can inspect the data and autocomplete the column names in the select statement, completely opposite of what is possible inSQL With a free order, you'd be able to start SQL queries with `FROM table_name SELECT ...` and have columns autocompleted.
- cm2187 7y agoSorry, I didn't mean that in defense of SELECT being first. I agree with the article that SELECT must come toward the end. And the first thing I tell people I teach SQL to is that they have to read SELECT last.
- wodenokoto 7y agoThen I misunderstood you post.