Srinabh Srinabh - 1 month ago 8
MySQL Question

Selecting multiple occurrence of specific column data

I need to select all the occurrences in gno which are repeated more than once, that is, i need to be able to select 1001 in this case, how do i do it?

create table project99
(
pno int primary key,
projtitle varchar2(30),
projarea varchar2(30),
startd date,
gno int references guide99(gno)
);

insert into project99 values(1,'E Commerce website','php','03-jan-2016',1001);
insert into project99 values(2,'Web forums','php','05-jan-2016',1001);
insert into project99 values(3,'Sudoku','C','06-jan-2016',1002);
insert into project99 values(4,'Student management System','php','04-jan-2016',1003);
insert into project99 values(5,'Antivirus','System','04-jan-2016',1004);
insert into project99 values(6,'Snake','C++','03-jan-2016',1004);
insert into project99 values(7,'Library management','php','03-jan-2016',1006);
insert into project99 values(8,'Video Sharing website','C#','03-jan-2016',1005);
insert into project99 values(9,'Search Algorithm','maths','03-may-2016',1010);
insert into project99 values(10,'Email','php','03-jan-2016',1007);

Answer
SELECT gno
  FROM project99
 GROUP BY gno
HAVING COUNT(1) > 1;
Comments