Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare equality b/w rows of the same column in a table

Status
Not open for further replies.

binita2908

Programmer
Nov 14, 2007
4
US
Hi ,

I am quite a baby in sql programming , please help me.

I have a table as follows :

mysql> select * from PC;
+------+-------+-------+------+------+------+-------+
| code | model | speed | ram | hd | cd | price |
+------+-------+-------+------+------+------+-------+
| 1 | 1232 | 500 | 64 | 5 | 12x | 600 |
| 2 | 1121 | 750 | 128 | 14 | 40x | 850 |
| 3 | 1233 | 500 | 64 | 5 | 12x | 600 |
| 4 | 1121 | 600 | 128 | 14 | 40x | 850 |
| 5 | 1121 | 600 | 128 | 8 | 40x | 850 |
| 6 | 1233 | 750 | 128 | 20 | 50x | 950 |
| 8 | 1232 | 450 | 64 | 8 | 24x | 350 |
| 9 | 1232 | 450 | 32 | 10 | 24x | 350 |
| 10 | 1260 | 500 | 32 | 10 | 12x | 350 |
| 11 | 1233 | 900 | 128 | 40 | 40x | 980 |
| 7 | 1232 | 500 | 32 | 10 | 12x | 400 |
+------+-------+-------+------+------+------+-------+
11 rows in set (0.14 sec)

Find the hard drive (hd) sizes that are equal among two or more PCs.
Result set: hd

The result set shuould be as follows :
hd
5
8
10
14

 
SELECT hd FROM PC GROUP BY hd HAVING COUNT(*)>1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top