--- Phill Sparks <[EMAIL PROTECTED]> wrote: > An example of the full query is... > > SELECT SQL_CALC_FOUND_ROWS uri, COUNT(tag) AS related_tag_count > FROM ( > SELECT subject AS uri, object AS tag > FROM milk_properties prop > INNER JOIN milk_posts model > ON model.uri = prop.subject > AND model.status = "published" > AND model.parent = 'milk:blog' > WHERE > predicate="http://cuttlefish.com/schemas/cms/1.0/concepts/document/tags" > AND prop.subject <> 'posts/2008/04/13/how_to_customise_your_ssh_config' > AND prop.object IN ('SSH','config','unix','howto') > ) AS tags > GROUP BY uri > HAVING COUNT(tag) > 0 > ORDER BY COUNT(tag) DESC, uri DESC > > Which I had shortened for the sake of readability and perhaps also > given myself the answer at the same time. We have a table called > milk_properties that contains _everything_ (uri, subject, predicate > and object make up absolutely everything we store) and index tables > for each of the types of content, like the blog (milk_posts). I think > I'm going to see if I can find a way of doing all this without the > join, then I can remove the subquery and that should solve it? I > wonder if I can make another index table for all the tags to live in, > like my first SQL. > > The error was "Invalid use of group function" > > Phill
The SQL_CALC_FOUND_ROWS was new to me so I looked it up and found this page http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#function_found-rows which suggests that it needs to be used in conjunction with a found_rows() function. I wonder if all of this is necessary or if it is being over engineered. Are there particular advantages you are trying to leverage with this syntax? Getting back to your initial issue, I don't know when some of these features were added and that could be confusing the older version of MySQL you are using. The PHP doc pages give better information on when a feature is added. James
