From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
To: PHP DB <email@example.com>
Date: Sat, 10 Dec 2005 20:04:28 -0500
Message-Id: <[EMAIL PROTECTED]>
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 =
... Add "GROUP BY conversation_user_id" or whatever column you use to
identify the user.
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 :
Cheers - Neil
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php