Register Lost Password?  Cookie?
  The time now is 04:32 PM GMT -6.  
Banshee Network
 
Quick Links
 
 
GameBanshee Swag
Site Features
Submit News
News Archives
Join Our Staff
Forums
Community Blogs
Reviews
Previews
Interviews
Editorials
About GB
Advertise With Us!
Advertisement
 
Go Back   GameBanshee Forums > Blogs > Xandax

Rate this Entry

SQL oddity.

Posted 09-11-2007 at 06:31 AM by Xandax
I ran into a SQL oddity today - or at least I think it's an oddity.
It revolves around case statements and column aliases, and for some reason you can't use column alias in a case statement. At least neither in the select nor order by clause.

For example:
Code:
SELECT myColumn as C
FROM myTable
ORDER BY C
This works perfetly well.

Now spice it up with a case (for what ever reason)

Code:
SELECT myCoulmn as C
FROM myTable
ORDER BY 
 CASE myCondition
   WHEN myValue THEN C
 END
This for some reason fails because it can't find column C......

I've yet to find the actual reason for why this happens, but that looks odd to me, and it is quite limiting at times.
Posted in Technical
Comments 0 Email Blog Entry
Total Comments 0

Comments

 
Recent Blog Entries by Xandax

 
      Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
© 2000-2008 GameBanshee.com