[PHP-DB] AP2
Hi all, has someone heard about the AP2 web application server (www.petroffcse.com/systems/ap2)? I just want to know how it really works and if it is really usefull. Thanks! - Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez le ici !
[PHP-DB] Subject: GROUP BY [Was: SELECT]
From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: PHP DB Content-Type: text/plain Date: Sat, 10 Dec 2005 20:04:28 -0500 Message-Id: <[EMAIL PROTECTED]> 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/en/group-by-functions.html Cheers - Neil -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: SELECT
Ron You want SELECT DISTINCT ... or SELECT FROM GROUP BY In either case you probably can't use SELECT * - you have to specify the columns you're after. This is because these commands will look for any differences and if they see one they'll give you a new row; if all you're after is the userID use SELECT DISTINCT userID ... this will only return a particular value once. See the documentation for your particular DBMS; GROUP BY is the more powerful with all kinds of aggregate functions available but sounds like SELECT DISTINCT will work fine for what your after. Good Luck, Frank On Dec 10, 2005, at 5:02 PM, [EMAIL PROTECTED] wrote: From: "Ron Piggott (PHP)" <[EMAIL PROTECTED]> Date: December 10, 2005 5:04:28 PM PST To: PHP DB Subject: SELECT Reply-To: [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 = $conversation_currently_displayed"; $response_created_by = mysql_result($result,$i,"response_created_by"); My ideal is that if users 1, 2, 4 & 5 are in dialogue with each other the above SELECT $query will only give the results of their identity once with the mysql_request() function Thanks for your help. Ron