Re: how to select rows with repeated coloumns in one query????

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



with Mysql 4.0 and above, u can use subqueries, so that u can put first
query in the where clause of second query itself.

Nitin

----- Original Message ----- 
From: "Saurabh Dhawan" <saurabh.dhawan@naukri.com>
To: <php-db@lists.php.net>
Sent: Tuesday, September 30, 2003 11:26 AM
Subject:  how to select rows with repeated coloumns in one query????


> 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')
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux