I tried using this query:
"SELECT * FROM guests WHERE event_id =". $ id. "GROUP BY member_id;"
and I get this error:
ERROR: the column "guests.id" should appear in the GROUP BY clause or be used in the aggregate function
can someone explain how i can get around this?
You cannot Group By without letting Select know what to take and how to group.Try
SELECT guests.member_id FROM guests WHERE event_id=".$id." GROUP BY member_id;
IF you need to get additional information from this guest table, you need to add it to the group.
It also seems that your choice should be
SELECT guests.id FROM guests WHERE event_id=".$id." GROUP BY id;
, group by, (.. SELECT * FROM ...), - (min/max/sum/avg/count/etc) group by.
group by
SELECT * FROM ...
:
SELECT instrument, detector, min(date_obs), max(date_obs) FROM observations WHERE observatory='SOHO' GROUP BY instrument, detector;
Source: https://habr.com/ru/post/1745488/More articles:Create all unique crosswords - crosswordVisual Studio Voodoo Debugger - debuggingInsert text into text field using .load () in jQuery - jquerySVN command A clean list of files changed between branches - linuxToolbar - .netWhat is the best practice of including jQuery ext functions? - jqueryRuby on Rails - adding a variable to parameters [] - variablesHow can I specify different layout sizes for different densities - androidReal pagination with Next and Previous buttons - phpHow can I create a DOTNET COM joint assembly for a classic ASP that does not block other threads? - c #All Articles