The Artima Developer Community
Sponsored Link

.NET Buzz Forum
SELECT * WHERE % ORDER BY why ?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter van Ooijen

Posts: 284
Nickname: petergekko
Registered: Sep, 2003

Peter van Ooijen is a .NET devloper/architect for Gekko Software
SELECT * WHERE % ORDER BY why ? Posted: May 25, 2005 2:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter van Ooijen.
Original Post: SELECT * WHERE % ORDER BY why ?
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter van Ooijen
Latest Posts From Peter's Gekko

Advertisement
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 ?


Read: SELECT * WHERE % ORDER BY why ?

Topic: Webservice Thinking - thoughts on Sahil's blog entry Previous Topic   Next Topic Topic: If I were Peter Frampton..

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use