Re: SELECT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx www.the-spectrum.org ------oOo---------------oOo------ ----- Original Message ----- From: "Ron Piggott (PHP)" <ron.php@xxxxxxxxxxxxxxxxxx>
To: "PHP DB" <php-db@xxxxxxxxxxxxx>
Sent: Sunday, December 11, 2005 11:04 AM
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";

$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



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux