On Tue, Jan 30, 2001 at 11:06:47AM -0500, Seger, Jeffrey wrote:
>
> Is it possible to use placeholders in an order by clause? The code
> below executes fine but is not sorted correctly.
>
> $sth = $dbh->prepare("SELECT projectnumber, companyname, engineer
> FROM project
> WHERE projectmanager =
> '$fullname' AND projectclass = 'Active'
> ORDER BY ?");
>
> $sth->execute(projectnumber);
>
> Obviously I will replace "projectnumber" in the execute statement with a
> variable if/when the above works. I have used placeholders successfully
> in other areas so I know they work with my db.
You can always use
select * from table
where something = something_else
order by decode(?, 'projectnumber', projectnumber,
'projectclass', projectclass);
--
------------------------------------------------------------------------
Honza Pazdziora | [EMAIL PROTECTED] | http://www.fi.muni.cz/~adelton/
.project: Perl, mod_perl, DBI, Oracle, auth. WWW servers, XML/XSL, ...
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------