ShootingBlanks Posted May 29, 2008 Share Posted May 29, 2008 Hello. I have a result set from a MySQL query that has some duplicates, but I want to list each instance only once... ...So, let's say I had a database column called "letters" that had the letters A-J in it. Then let's say that my result set from my query was: A, A, B, C, F, F, F, F, G, I, I, J (the reason for the duplicates are because of a join query with another table) I would want to "echo" each letter in my result set only once. So, I'd like to list out: A, B, C, F, G, I, J How would that be possible? Thanks!!! Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted May 29, 2008 Share Posted May 29, 2008 Use DISTINCT SELECT DISTINCT(letters) FROM ... Quote Link to comment Share on other sites More sharing options...
ShootingBlanks Posted May 29, 2008 Author Share Posted May 29, 2008 Use DISTINCT SELECT DISTINCT(letters) FROM ... But I still need all the rest of the result set. So, for instance (to elaborate on my original example) instead of simply saying that my result set was: A, A, B, C, F, F, F, F, G, I, I, J ...let's say that it's actually: COL1 COL2 A 1 A 2 B 3 C 7 F 3 F 4 F 2 F 5 G 1 I 6 I 1 J 3 If I used "DISTINCT", then wouldn't I only get one of each letter's entry? (so, like, I may get the "A, 1" result but not the "A, 2" result, right?)... Using the 2-column result I just wrote above, my ultimate goal is something like this (which should give you more insight as to why I asked my original question): A 1 2 B 3 C 7 F 3 4 2 5 G 1 I 6 1 J 3 Thanks! Quote Link to comment Share on other sites More sharing options...
ShootingBlanks Posted May 29, 2008 Author Share Posted May 29, 2008 EDIT: - NEVERMIND! I got it to work using a 2nd query with that "DISTINCT" keyword. Thanks so much for the help!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.