[Typo3-dev] Nested Queries in MySQL wrapper class
Daniel Pötzinger
operation-lan at gmx.de
Thu Jul 15 21:22:17 CEST 2004
Joel Faucett schrieb:
> Hello all-
> How does one implement nested queries in the wrapper functions? e.g.
> I want to get the 5 most recent items sorted by title, but the following
> code returns an empty result. Is it an SQL error that I'm not seeing or
> have I structured it incorrectly?
>
> $innerQuery = 'SELECT uid FROM tx_tekresearch_sum ORDER BY crdate DESC
> LIMIT 5';
> $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
> '*', // SELECT ...
> 'tx_tekresearch_sum', // FROM ...
> 'uid IN ('.$innerQuery.')', // WHERE...
> '', // GROUP BY...
> 'title', // ORDER BY...
> '' // LIMIT ...
> );
>
I am not sure but subqueries are not supported in every mysql version so
be careful?
Yust a few ideas for other solutions related to your problem:
-> make two seperated queries
-> make one query and because there are only 5 items sorting with php
would be ok.
More information about the TYPO3-dev
mailing list