Index: class.t3lib_db.php =================================================================== --- class.t3lib_db.php (revision 2190) +++ class.t3lib_db.php (working copy) @@ -453,11 +453,20 @@ // Table and fieldnames should be "SQL-injection-safe" when supplied to this function // Build basic query: - $query = 'SELECT '.$select_fields.' - FROM '.$from_table. - (strlen($where_clause)>0 ? ' + $query = 'SELECT '.$select_fields; + + // table(s) (this may be empty e.g. for "SELECT 1") + if (strlen($from_table)) { + $query.= ' + FROM '.$from_table; + } + + // Where: + if (strlen($where_clause)>0 ) { + $query.= ' WHERE - '.$where_clause : ''); + '.$where_clause; + } // Group by: if (strlen($groupBy)>0) {