Why not remove the word "where" from the SQL statement [message #614420] |
Wed, 21 May 2014 10:10  |
Amine
Messages: 376 Registered: March 2010
|
Senior Member |

|
|
Hi all,
I was asking myself why the new standards of SQL have always the word "where" in there specifications.
In the first times it was called (Structured English Query Language), so the SQL statement "had" to look like an English sentence.
But now, the SQL is more and more technical. And where is the problem if we write the SQL statement as this :
select a.*
from a, b
and a.id = b.id
and a.cpt > 1;
Thanks in advance for sharing your opinions,
Amine
|
|
|
|
|
|
|
|
|
|
Re: Why not remove the word "where" from the SQL statement [message #614454 is a reply to message #614452] |
Wed, 21 May 2014 13:45   |
John Watson
Messages: 8965 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
Hi, BB - I've missed your posts recently.
Back to the topic:
If we are going to re-write the ANSI SQL standard, I would like to replace SELECT with PROJECT. For example,
PROJECT ENAME,DNAME FROM EMP NATURAL JOIN DEPT WHERE SAL < 3000;
Rows are selected, columns are projected. I get irritated when people talk about "selecting columns", which shows you that, in Freudian terms, I must be a very anally retentive person.
|
|
|
|
Re: Why not remove the word "where" from the SQL statement [message #614471 is a reply to message #614454] |
Thu, 22 May 2014 01:08  |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
John Watson wrote on Thu, 22 May 2014 00:15
If we are going to re-write the ANSI SQL standard, I would like to replace SELECT with PROJECT. For example,
PROJECT ENAME,DNAME FROM EMP NATURAL JOIN DEPT WHERE SAL < 3000;
I second you. And I have some more thoughts.
With the filter predicate, it is more appropriate and meaningful to have SELECT. Since we are selecting the rows based on a condition. Had it been without a condition, then I vote for you. "PROJECT columns FROM table" is more meaningful as it is simply projection of columns.
Now that would be a different discussion altogether whether we could have both the keywords based on the operation. We could write PROJECT when we are sure not to have any condition based selection. And if someone puts a WHERE clause it must throw an error "Filter predicate not allowed with PROJECT" or something like that.
And guess what, it would also make the developers use the ANSI syntax more and more. Because, when the PROJECT keyword won't allow the WHERE clause, it would be impossible to join the tables using old Oracle join syntax. So I believe we must have SELECT and PROJECT both and should be used as appropriate keywords based on the operation(selection of rows or projection of columns).
|
|
|