Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Subject: GROUP BY [Was: SELECT]

>From: "Ron Piggott (PHP)" <ron.php@actsministries.org>
>Reply-To: ron.php@actsministries.org
>To: PHP DB <php-db@lists.php.net>
>Content-Type: text/plain
>Date: Sat, 10 Dec 2005 20:04:28 -0500
>Message-Id: <1134263069.3515.86.camel@localhost.localdomain>
>Mime-Version: 1.0
>Content-Transfer-Encoding: 7bit
>Subject: SELECT
>
>I am trying to put together a SELECT syntax.  I am querying a response
>database and I only want to obtain each user's name once even if they
>have given more than 1 response.
>
>$query="SELECT * FROM  conversation_table WHERE conversation_reference =
>$conversation_currently_displayed";

... Add "GROUP BY conversation_user_id" or whatever column you use to
identify the user.

http://dev.mysql.com/doc/refman/5.0/en/select.html

Note that GROUP BY comes *before* any ORDER BY in your select (which
you aren't doing). By default, MySQL will order by the grouped
columns initially. Other databases you'd have to include the GROUP BY
column(s) in the select * statement, but MySQL allows you to do this
with non-selected fields as well.

Then spend some time on the MySQL site looking at the 'aggregate
functions' area now you've grouped the results - you'll find some
useful stuff you can do once that's happened :

http://dev.mysql.com/doc/refman/5.0...-functions.html

Cheers - Neil

Report this thread to moderator Post Follow-up to this message
Old Post
Neil Smith [MVP, Digital media]
12-11-05 12:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PHP DB archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 03:36 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.