DROP TABLE IF EXISTS `temp`;
CREATE TABLE `temp` (
`nr` int(10) NOT NULL);
insert into temp (nr) select c.guid
from gameobject c
inner join ( select id, map, position_x, position_y, position_z, max(guid) maxguid from gameobject group by id, map, position_x, position_y, position_z
having count(*) > 1
) s on c.id = s.id and c.map = s.map and c.position_x = s.position_x and c.position_y = s.position_y and c.position_z = s.position_z
where c.guid <> s.maxguid and c.guid not in (select guid from game_event_gameobject );
select * from gameobject where guid in ( select nr from temp ) order by position_x asc;
DROP TABLE IF EXISTS `temp`;