PHP Questions Home
Categories
Arrays
Files
Forms
Creating PDFs
PHP Errors
Functions
Images
MySQL
Numbers
Others
Strings
Website

PHP Forums
Forums Index
MySQL Forum
PHP Forum
Flash/Actionscript
Javascript
Web design

More PHP
PHP Functions
Top Questions
Ask a Question
PHP Interview Questions
PHP Jobs
Ecommerce
IT Questions
Business Websites

Sponsors

sponsor ad
My Salary
PHP Developer Salary
Advertise Here

How do I group the results of a mysql query?


If you want to group the results by a particular field value rather than listing all results individually, then you use the GROUP BY keyword.

Here is how the query might look:

SELECT columns FROM Table WHERE clause GROUP BY column ORDER BY column

Common mistakes are to apply the GROUP BY either before the WHERE clause or after the ORDER BY - make sure you get it right.

Also remember that you are returning aggregate data rather than every result as an individual row, therefore it can take a little bit of careful thinking as to when you should use GROUP BY and a realisation of what will be returned when you do.

ASK A QUESTION

More mysql PHP Questions

how can I show an image from mysql?

How do I delete a row from a table?

How do I include a conditional in my mysql query?

What is difference between mysql_fetch_array and mysql_fetch_object?

I'm creating a table to store clients' info via PHP; can I make an inquiry field where the client can enter comments about their inquiry?



Custom Search