[Typo3-dev] Nested Queries in MySQL wrapper class
Rainer Kuhn
kuhn at punkt.de
Fri Jul 16 08:44:02 CEST 2004
Joel Faucett wrote:
> 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 ...
> );
Hi Joel,
maybe this is the issue:
http://dev.mysql.com/doc/mysql/en/Subquery_errors.html
This means that statements of the following form will not work, although
this happens only in some early versions, such as MySQL 4.1.1:
SELECT * FROM t1 WHERE s1 IN (SELECT s2 FROM t2 ORDER BY s1 LIMIT 1)
# Unsupported subquery syntax:
ERROR 1235 (ER_NOT_SUPPORTED_YET)
SQLSTATE = 42000
Message = "This version of MySQL doesn't yet support
'LIMIT & IN/ALL/ANY/SOME subquery'"
Cheers,
Rainer
More information about the TYPO3-dev
mailing list