• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

[MySQL] Selecting data using DISTINCT

I have the following table (for a forum I am building):
| threadid | postid | userid | name       | title        | body       |
|        1 |      1 |      0 | Glaanieboy | No title     | Hello!!!   |
|        1 |      2 |      0 | Glaanieboy | RE: No title | Hi!!!      |
|        2 |      3 |      0 | G-Man      | Welcome!     | I am here! |
What I want is to select threadid, name and title, but only the distinct two threadid's, meaning I should get a result like this:
| threadid | title        | name       |
|        2 | Welcome!     | G-Man      |
|        1 | No title     | Glaanieboy |
I have tried using the query: "SELECT DISTINCT threadid, title, name FROM forum ORDER BY threadid DESC;", but that shows also the double threadid's, it's like I used a query without the DISTINCT part. Can someone help me please?

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
What a long strange trip it's been. =)

Forum statistics

Latest member