[TYPO3-dev] Order result of query based on comma-seperated string
ries van Twisk
typo3 at rvt.dds.nl
Thu Oct 2 16:39:46 CEST 2008
On Oct 2, 2008, at 1:20 AM, Sacha Vorbeck wrote:
> Hello Oliver,
>
>> The 5th parameter of SELECT_query() can be set to the sort column
>> of the
>> table. But I guess you'd like to have a very specific sorting as
>> provided in the string $bookIDs ("3,1,4,2")?
>
> exactly.
>
> Therefore you can use the
>> "ORDER BY FIELD()" in MySQL - however this query is not very
>> efficient
>> compared to database normalization...
>
>> 'FIELD(uid, ' . $bookIDs . ')',
>
> thank you very much. Efficiency is not that important here as there
> are
> only a few records. But of course it would be better to otimize things
> right from the start. So what would be the best/most efficient way to
> code this? Do the sorting in PHP?
>
> --
> all the best,
> Sacha
you can specify the order in the order by clause much like you can do
with the IN clause.
I forgot the exact syntax but I would suggest to look this up in the
MySQL manual.
this might give you a hint : http://www.webmasterworld.com/forum88/7086.htm
regards, Ries van Twisk
-------------------------------------------------------------------------------------------------
Ries van Twisk
tags: Freelance TYPO3 Glassfish JasperReports JasperETL Flex Blaze-DS
WebORB PostgreSQL DB-Architect
email: ries at vantwisk.nl
web: http://www.rvantwisk.nl/
skype: callto://r.vantwisk
More information about the TYPO3-dev
mailing list