Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Complex query

 
Dmitry Shekhter
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently in a situation where i have to write a query, the WHERE clause of which is a bit unusual. In the WHERE clause it is not the values to be compared that are variable, it's the columns themselves that are variable. The situation is such:
As I am retreiving the rows, part of the where clause depend on the value of one of the columns that I'm retrieving. Basically if TableA.columnB = 1, then in my WHERE clause i have to compare TableZ.columnA and TableZ.columnB or if TableA.columnB=2, then i have to compare TableZ.columnC and TableZ.columnD. Of course I dont know the value of TableA.columnB until the actual statement is run.
I'm trying to figure out the best way to do this in terms of performance, ease of maintenance,etc.
Any help would be appreciated.
Thanks
Dmitry
 
Lu Battist
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understood it right, the following where clause should work:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic