Nov 16, 2004 #1 timmyni Programmer Nov 16, 2004 3 GB I have a table users( ...... age int .........) I want to pick out the users have same age as anyother users. with one SQL statement. How can I do it?
I have a table users( ...... age int .........) I want to pick out the users have same age as anyother users. with one SQL statement. How can I do it?
Nov 16, 2004 #2 r937 Technical User Jun 30, 2002 8,847 CA Code: select foo, bar, age from users where age in ( select age from users group by age having count(*) > 1 ) rudy http://r937.com/ SQL Consulting Upvote 0 Downvote
Code: select foo, bar, age from users where age in ( select age from users group by age having count(*) > 1 ) rudy http://r937.com/ SQL Consulting
Nov 25, 2004 Thread starter #3 timmyni Programmer Nov 16, 2004 3 GB how about this one select id, age from users where age in ( select age from users group by age having count(*) > 1 ) Upvote 0 Downvote
how about this one select id, age from users where age in ( select age from users group by age having count(*) > 1 )
Nov 25, 2004 Thread starter #4 timmyni Programmer Nov 16, 2004 3 GB sorry, pasted the wrong one, SELECT DISTINCT t1.* FROM try1 AS t1 INNER JOIN try1 AS t2 ON t1.age = t2.age AND t1.id <> t2.id Upvote 0 Downvote
sorry, pasted the wrong one, SELECT DISTINCT t1.* FROM try1 AS t1 INNER JOIN try1 AS t2 ON t1.age = t2.age AND t1.id <> t2.id