Jump to content


easy distinct question

  • Please log in to reply
2 replies to this topic

#1 thejayjay

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 22 January 2003 - 12:37 PM

i want to select some additional fields from my table, but they don\'t need to be distinct. how do i do that?

#2 pallevillesen

  • Members
  • PipPipPip
  • Advanced Member
  • 135 posts
  • LocationDenmark

Posted 22 January 2003 - 03:15 PM

Well, it is not possible in a single query to get distinct values from one coloumn (field) and multiple hits from another coloumn.

If that is what you want you must make a subselect which is not directly possible, but you may use temporary tables (see other threads).

An alternative is to get the not-distinct results and then parse the coloumn you want to be distinct, i.e. sort the rows on the coloumn you want to be distinct and then only grab unique values from this coloumn.

Another alternative is to return distinct values first, then for each distinct value do a non-distinct query with this value in the WHERE clause (again using php or perl or some other language).

Of all of the above I like temporary tables most or the parsing solution, since several sql queries might be quite slow.

If you want us to be more detailed then you should post a more detailed description of your tables, fields and so on. Including your current sql query!

I hope this will get you further,
P., denmark
Palle Villesen, www.birc.dk [br]Bioinformatics Research Center

#3 thejayjay

  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 22 January 2003 - 09:10 PM

that was the answer that i was looking for and was pretty much what i had determined from looking for information online.

thanks for clearing it up for me!


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users