$construct = “SELECT * FROM mytable GROUP BY nid HAVING nid>1”;
mytable:
+----+----------+
| id | nid |
+----+----------+
| 1 | null |
| 2 | 1 |
| 3 | 1 |
| 4 | 1 |
| 5 | 2 |
| 6 | 2 |
| 7 | 3 |
| 8 | 3 |
| 9 | 4 |
| 10 | 4 |
-----------------
How do i GROUP BY nid except nid=1? This is a brief example but with my code i am not getting the desired results. Is the query correct for what i am trying to accomplish?
How about this:
GROUP BYcauses an aggregate query which you can only sensibly use with an aggregation function. For example,SELECT COUNT(*), nid GROUP BY nidwould give you the counts of rows with a givennid.Update: Not sure I’m understanding you, but how about this then:
I’m not sure it makes sense to mix aggregate and non-aggregate queries, though — on the aggregate side you’ll just end up with an indeterminate representative row of that group.