June 2005
Intermediate
720 pages
20h 6m
English
In the preceding chapter, two different clauses—ORDER BY and LIMIT—were introduced as ways of affecting the returned results. The former dictates the order in which the selected rows are returned; the latter dictates which of the selected rows are actually returned. This next clause, GROUP BY, is different in that it works by grouping the returned data into similar blocks of information. For example, to group all of the URLs by category, you would use
SELECT * FROM url_associations, urls → WHERE url_associations.url_id=urls. → url_id GROUP BY url_category_id
The returned data is altered in that you’ve now aggregated the information instead of returned just the specific itemized records. So where you might have seven ...
Read now
Unlock full access