Sometimes you also need to change the query itself, i.e. the tables that are joined, or the sort order.
Re:A Big Case of Oops
by jasonkester on Friday February 26, 2010 @04:35PM
(#1154213)
Indeed. And you either do that in Stored Procedures using parameters that you've passed in (without manipulating them as strings), or you construct your parameterized query on the webserver with the joins and sorts that you need, and then pass it to the database along with the parameters it needs to stick in.
Like I said. It's a solved problem, and has been so for a dozen years now.
It's amazing that people are still constructing SQL queries as strings in 2010.