Jump to content

easy distinct question


thejayjay

Recommended Posts

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.