[Typo3-dev] change default sorting of MySQL WHERE - IN
"Rafael Schär [beYou media]"
typo3 at goldkueste.ch
Thu Sep 15 01:41:26 CEST 2005
Sacha Vorbeck wrote:
> Hi,
>
> when I select multiple records from tt_content using the following query:
>
> SELECT uid
> FROM tt_content
> WHERE
> uid in (3765,3764,34,88)
> (additional enableFields checks go here)
>
> which is the result of:
> $addwhere= $GLOBALS['TSFE']->cObj->enableFields('tt_content');
> $result=$GLOBALS['TYPO3_DB']->exec_SELECTquery('uids','tt_content',"uid
> in ($content_list) ".$addwhere);
>
> MySQL sorts the result with UID asc:
> 34,88,3764
>
> But I need the uids in the original order:
> 3764,34,88
>
> Any ideas on how I can achieve this?
>
Hey Sascha,
I guess you should use this mysql order routine, but I am not sure if
understand what exactly is your challenge.
Anyway here is my aproach:
$values = 3764,34,88;
ORDER BY FIELD (uid, $values);
http://dev.mysql.com/doc/mysql/en/sorting-rows.html
Hope this helps
greetinx
Rafael
More information about the TYPO3-dev
mailing list