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

-- 
John Hinton - Goshen, VA.
http://www.ew3d.com

Those who dance are considered insane 
by those who can't hear the music....

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

Reply via email to