Stuck on this join temp (MySQL ver 3.23)

>From one table I need:

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.prikeyfield0 = temp.prikeyfield0 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.prikeyfield0 is not being
collected
into the temp table, but as prikeyfield0 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 or
perhaps DISTINCT has very few options?

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

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

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to