You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Tulsi Das <qu...@yahoo.com> on 2003/10/07 23:31:46 UTC

Alias order by problem...

Hello, using Torque with MySQL I want to do an "order by" using some
alias column and not a table column. That is, something like this:

SELECT actividad.*, MATCH (actividad.ACTIVIDAD) AGAINST ('futbol') AS
score FROM actividad 
WHERE MATCH (actividad.ACTIVIDAD) AGAINST ('futbol') order by score
desc


that is, using full text seach, sort by the score of that result.

To achieve that, I use the following code:

String matchString = "MATCH ("+ActividadPeer.ACTIVIDAD+") AGAINST
(\'"+texto+"\')";

Criteria crit = new Criteria();		
crit.add(ActividadPeer.ACTIVIDAD, (Object)matchString,
Criteria.CUSTOM);
		
crit.addAsColumn("score", matchString);
crit.addDescendingOrderByColumn("score");

List actividades = ActividadPeer.doSelect(crit);

If I comment the addDescendingOrderByColumn line, everything goes well
and the full text goes ok, but when trying to do the order by, I get
the following error:

org.apache.torque.TorqueException: Malformed column name in Criteria
order by: 'score DESC' is not of the form 'table.column'


Now... I know it what it means, but I don´t want a table.column form,
since it´s an alias!

Any input on the subject will be much appreciated

thanks

Tulsi

------------
Internet GRATIS es Yahoo! Conexión
4004-1010 desde Buenos Aires. Usuario: yahoo; contraseña: yahoo
Más ciudades: http://conexion.yahoo.com.ar

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org