how to select rows with repeated coloumns in one query????
| From: | Saurabh Dhawan | Date: | Tue, 30 Sep 2003 05:56:16 +0000 |
| Subject: | how to select rows with repeated coloumns in one query???? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-30761@lists.php.net to get a copy of this message | ||
I have a table called studs with coloumns as :
Sno. name grade
1 aa 1
2 bb 1
3 cc 2
4 dd 3
5 ee 4
6 ff 4
7 gg 4
8 hh 5
Now i want to see only those rows which have value of grade repeated atleast in one other row i.e.
The result should contain row no's 1,2(with grade 1) and 5,6,7(with grade 4)
in two queries this cud be done as :
select sno, count(grade) as cnt from studs group by grade having cnt>1
and then
select * from studs where sno in ('result of previous query')