A sql select query looks something like this :
SELECT MyCol FROM MyTable WHERE MyCol = 'A' ORDER BY Mycol
It has a couple of parts
- SELECT FROM specifies the output columns
- WHERE specifies the rows
- ORDER BY specifies the sort order of the output rows
What puzzles me is that the order of these three parts is fixed. I cannot interchange parts and state my query like this
SELECT MyCol FROM MyTable ORDER BY Mycol WHERE MyCol = 'A'
In my simple view that would be no big deal for the SQL parser. But it
(the SQL server one) will throw an error at you. I think this is a
pitty; else it would be oh so easy to further specify the WHERE clause
like:
[AirCode]
string mySQL = "SELECT MyCol FROM MyTable ORDER BY Mycol WHERE MyCol = 'A'"
if (TextBoxName.Text != "")
mySQL+= " AND Name Like @Parameter1"
Am I overlooking something or is this just sql syntax rigidity ?