Re: GROUP BY clause not working



Lorenzo Thurman wrote:
I'm using PHP 5 to make an ODBC connection to an MS Access database using PEAR and I'm getting DB Error: Syntax Error when using the GROUP BY clause. Here's my query:
SELECT * FROM HardwareInstallationsSummary WHERE LocationID = $loc_ID GROUP BY EquipmentTypeID

You have only told it *what* to group together, but it also needs to know *how* it should do it.

Just for kicks, I changed the GROUP BY to ORDER BY. The query works, and the items are sorted as expected, but this is not what I want. Is there a bug in here somewhere?

You need to spell it out for the ms-access thingy. As Janwillem mentions, you use aggregate functions for that, and there might be differences between different systems. So try at "comp.databases.ms-access", and give them a bit more information about the columns of the table you select from, and what you expect to happen.


/Bent
.



Relevant Pages

  • Re: problem to SELECT using Microsoft Access (posted again, because of posting error)
    ... I tested that query. ... I get an error "syntax error in from clause" which is ... becuase Table is a reserved word ...
    (borland.public.delphi.database.ado)
  • Re: probably not as complex as Im thinking...
    ... No, sorry, I get a syntax error in Group By clause here, and I tried not ... >> OK, I have 4 queries, the SQL view of which I have below, with brief ... Please understand that I use the Query Design Grid to make ...
    (microsoft.public.access.queries)
  • Re: Please help ~ Syntax Error
    ... If this is not for a query, then you will need to change it to use ... The only time the error stops, see below, but then the report doesn't ... So perhaps I should try another approach, maybe my unbound form wasn't ... Syntax error in query expression '(Between ...
    (microsoft.public.access.formscoding)
  • Re: Calculating totals on a Crosstab Query
    ... you are getting closer qrysheds and qryTotal works ... syntax error in query Expression Count(IIf((Is ... FROM QDailyWheplingReport2 ...
    (microsoft.public.access.reports)
  • Re: Duplicate records ... sort of
    ... the query has come back with a syntax error ... FROM tblRegions as R INNER JOIN tblContacts as C ... FROM tblRegions INNER JOIN tblContacts ON tblRegions.RegionID = ...
    (microsoft.public.access.queries)