Re: SELECT

From: Date: Sun, 11 Dec 2005 02:01:43 +0000
Subject: Re: SELECT
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-40842@lists.php.net to get a copy of this message
Have you considered the GROUP BY statement of SQL?? For example if this is a table's data:
msg_id        user        varname        value
2               1            yada                hello
3               1            yada                hows it going?
4               2            yada                its me! Zonk!
6               1            turmoil            anyone here seen that movie before?
8               2            turmoil            oh yeah, years back!
9               1            yada                and that means??
you can: $request_varname="yada"; SELECT * FROM the_table WHERE varname = "$request_varname" GROUP BY user HAVING max(msg_id) If I can recreate my "in brain" SQL engine correctly this sql should work.. I'm not sure of exactly what your setup is like relating to storage of the data, and I'm not certain I understand what you are trying to retrieve with your query either, but I hope I'm heading down the right track.. I'm sure either way that its the GROUP BY predicate you are after.. enjoy!~ ---oOo--- Allowing users to execute CGI scripts in any directory should only be considered if: ... a.. You have no users, and nobody ever visits your server. ... Extracted Quote: Security Tips - Apache HTTP Server ---oOo--- ------oOo---------------oOo------ Julien Bonastre [The_RadiX] The-Spectrum Network CEO ABN: 64 235 749 494 julien@the-spectrum.org www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: "Ron Piggott (PHP)" <ron.php@actsministries.org> To: "PHP DB" <php-db@lists.php.net> Sent: Sunday, December 11, 2005 11:04 AM Subject: [PHP-DB] 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"; $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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.db (#40842) next »