Say I have a bunch of records in a table with a bunch of fields. One of
those fields is cluster_id. It is not unique. However, I want to make a
unique set. I want one record for each cluster_id value. I don't care
which record that is.

Right now, I do:
SELECT DISTINCT cluster_id FROM my_table

Then, for each of those I do:
SELECT * FROM my_table WHERE cluster_id=$cluster_id

I take the first record of the response and continue. This is very slow
because I'm accesing the database thousands of times instead of once.

SELECT DISTINCTROW * from my_table doesn't work either, because it sees if
ALL of the fields are DISTINCT, not just cluster_id, thus this is more
than I want.

Also, I would like to SELECT into another table. The MySQL docs only say
how to select into a file. This is not really what I want. What I do now
is SELECT and then INSERT each row.

Any suggestions?


                -rishi


---------------------------------------------------------------------
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