Re: SQL DISTINCT with MYSQL
| From: | fLIPIS | Date: | Mon, 17 Mar 2003 10:38:01 +0000 |
| Subject: | Re: SQL DISTINCT with MYSQL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-139922@lists.php.net to get a copy of this message | ||
"Vernon" <vernon@comp-wiz.com> escribió en el mensaje
news:20030314002348.83696.qmail@pb1.pair.com...
> I'm setting up a user online system using MySQL where I have 4 fields, all
> of which is working fine.
>
> I need the information from all the fields but want only distinct values
> based on the uname column. If I use the:
>
> SELECT DISTINCT uname
> FROM useronline
>
> of course I come back with the values I desire, but only the user names.
>
> As I am also tracking the page they are on I need other columns in the
table
> as well. So the question is, using an SQL statement, how do I return only
> distinct useronline.uname values from the database as well as the
> useronline.file column?
>
> Thanks
You can try using an INNER JOIN syntax. Like this:
SELECT DISTINCT(useronline.uname) FROM useronline INNER JOIN file ON
file.useronline = useronline.name WHERE useronline.uname LIKE'
%your_Criteria_1%' AND file.useronline LIKE '%you_criteria_2%'
I dunno if this is what you're looking for.
Hope it helps
fLIPIS