[TYPO3-dev] simple relation and records order

Christian Jul Jensen christian at jul.net
Tue Jun 6 09:37:02 CEST 2006


Bartosz Aninowski wrote:

> Let say my filed contains 9,3,5,3,7 and I want to make select
> select from my_tabel uid in (9,3,5,3,7) and return records in the same
> order Any hint? or I need to make more complex select?

Untested, but I think it will work:  ORDER BY FIND_IN_SET(uid,'9,3,5,3,7')

But it will probably not do what you want because you have multiple
occurences.

In that case I would use the function from t3lib_db, that returns an array
of the result and give the uid is the parameter to use as key. Then you
will have an array of results that you can access directly using the uid,
and then construct the result. Since you don't need to do any sorting in
php, I don't think you will loose a lot of performance.

-- 
- Christian Jul Jensen

TYPO3 core developer (http://TYPO3.org)
Professional webdeveloper (http://jul.net)





More information about the TYPO3-dev mailing list