On Wednesday 01 January 2003 00:21, John Hinton wrote:
> Stuck on this join temp

>
> From one table I need to
>
> mysql_query("CREATE TEMPORARY TABLE temp TYPE=HEAP SELECT DISTINCT
> field1, field2 FROM $table");
>
> both field1 and field2 have various repeating data and I need to return
> only the first occurance of the distinct data along with the rest of the
> data selected below for only those distinct rows.
>
> $result = mysql_query("SELECT $table.field3, $table.field2,
> $table.field1, $table.field4 FROM $table LEFT OUTER JOIN temp ON
> $table.indexfield0 = temp.indexfield0 ORDER BY $table.field1 DESC");
>
> Running the above kills the distinct select and returns all of the rows.
> I see where it is broken in that temp.indexfield0 is not being collected
> into the temp table, but as indexfield0 is a primary key, all values are
> distinct and when added to the select distinct statement, all rows are
> returned.
>
> Is there any way to
>
> SELECT field0, (DISTINCT field1, field2) FROM table? Sure would make
> this easy!
>
> or SELECT field0 WHERE DISTINCT field1, field2 FROM table?
>
> There seems to be very little information anywhere on DISTINCT

This looks suspiciously like a MySQL question, better to ask on the mysql 
list.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *

/*
The end move in politics is always to pick up a gun.
                -- Buckminster Fuller
*/


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

Reply via email to