INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

return all columns on one distinct column

return all columns on one distinct column

(OP)
I have a table with many columns, I want to return all columns but ignore duplicates based on one column

id | fullname | this | that | other
1 | Bob | 1 | 0 | 0
2 | Mary | 1 | 1 | 0
3 | Bob | 0 | 1 | 0

In the above example I need to only pull back one Bob row even though the data in fields other that fullname are different.

So I can't do

select distinct * from table

as this would pull back both Bobs

I can do

select distinct fullname from table

but this returns just the fullname column, I want all columns kind of like

select distinct fullname, * from table

but obviously that won't work. I tried a nested query and think that may be the way but am getting confused with that too

SELECT distinct fullname FROM (select * from table) as foo

How would I do this?

Thanks

RE: return all columns on one distinct column

(OP)
Thanks audiopro, you put me on the right track. My final working query is

SELECT *
FROM table t1
INNER JOIN table t2 ON t1.fullname = t2.fullname
GROUP BY t1.fullname

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close