sql - Select Record with common column field -
i have following table duplicate id.i want record duplicate id
create table student1 (`id` int,`status` int,`amount` int , `name` varchar(10), `date` varchar(55)) ; insert student1 (`id`,`status`,`amount`, `name`, `date`) values (1,0,4500, 'ram', '04/02/2012'), (2,0,2000, 'shyam', '05/09/2013'), (2,0,6500, 'radhe', '11/11/2014'), (2,0,8000, 'radheshyam', '15/11/2013'), (4,0,1500, 'ghanshyam', '08/11/2014') ; id status amount name date 1 0 4500 ram 04/02/2012 2 0 2000 shyam 05/09/2013 2 0 6500 radhe 11/11/2014 2 0 8000 radheshyam 15/11/2013 4 0 1500 ghanshyam 08/11/2014
query:
select * student1 group id having count(*)>1
result:
id status amount name date 2 0 2000 hyam 05/09/2013
expected result :
id status amount name date 2 0 2000 shyam 05/09/2013 2 0 6500 radhe 11/11/2014 2 0 8000 radheshyam 15/11/2013
try,
select * student1 id in (select id student1 group id having count(*)>1)
Comments
Post a Comment