Re: [SQL]

From: Chris Hope (blackhole_at_electrictoolbox.com)
Date: 10/29/04


Date: Fri, 29 Oct 2004 18:52:40 +1300

Wes S. wrote:

> Running: MySQL (version unknown)
>
> SELECT *
> FROM (
> SELECT ncf_news.news_id AS `news_id`,
> COUNT(ncf_news_comments.comment_id) AS `comments`
> FROM ncf_news
> LEFT OUTER JOIN ncf_news_comments
> ON (ncf_news.news_id = ncf_news_comments.nnw_news_id)
> GROUP BY news_id
> ) AS `sq`
> JOIN ncf_news
> ON (sq.news_id = ncf_news.news_id)
> WHERE disabled IS NULL;
>
> Can anyone help me with that query. All columns are valid. I'm getting an
> error with the SubQuery SELECT part. I know that the subquery alone will
> work.

Find out which version of MySQL you are using. If it is 4.0.x or lower there
*is no* support for subqueries. They were added only in 4.1.0 which has
only just had its production level release this week.

-- 
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/


Relevant Pages

  • Re: Jet SQL and Virtual tables/subqueries qiestions
    ... subquery, but it's curious... ... repeated trips through the Query Editor's "graphical" side did ... The Jet Expression Evaluator (what functions & stuff are actually ... within brackets within the query. ...
    (microsoft.public.access.queries)
  • RE: Display most recent comment in report
    ... There are parentheses around the subquery! ... I'm not sure just what you are doing, but the SQL statement is a query; ... FROM Projects INNER JOIN [Communications Log] AS CL1 ... NoteDate and Notes as their ControlSource properties. ...
    (microsoft.public.access.gettingstarted)
  • Re: Mangled, with a difference
    ... My experience with this subquery as a "table" in SQL in ACCESS (where ACCESS ... query will stop working if I create the query, save it, close it (and ACCESS ... I can't say that I've noted that the mangling differs on different PCs, ... inside the square brackets Access added which are themselves inside square ...
    (microsoft.public.access.queries)
  • Re: Calculate change from record to record
    ... another query that uses the crosstab query as an input "table." ... subquery in this new query. ... [Event Procedure] ...
    (microsoft.public.access.queries)
  • Re: Multiple AND criteria
    ... A subquery is like a whole SELECT query inside another query. ... Then switch it to SQL view to ... FROM tblPart INNER JOIN tblPartAttrib ...
    (microsoft.public.access.queries)