Select => Delete

Petit nouveau ! | 1 Messages

26 nov. 2008, 18:03

Bonjour,


Je souhaiterais transformer la requête suivante :

Code : Tout sélectionner

select * from (select count(entry) as pocet, entry, map, position_x, position_y, position_z from creature_spawns group by position_x, position_y, position_z order by pocet desc) a where a.pocet > 1
En requête type "DELETE FROM".


La table :

Code : Tout sélectionner

-- -- Structure de la table `creature_spawns` -- CREATE TABLE IF NOT EXISTS `creature_spawns` ( `id` int(11) unsigned NOT NULL auto_increment, `entry` int(30) NOT NULL, `map` int(30) NOT NULL, `position_x` float NOT NULL, `position_y` float NOT NULL, `position_z` float NOT NULL, `orientation` float NOT NULL, `movetype` int(30) NOT NULL default '0', `displayid` int(30) unsigned NOT NULL default '0', `faction` int(30) NOT NULL default '14', `flags` int(30) NOT NULL default '0', `bytes0` int(30) NOT NULL default '0', `bytes1` int(30) NOT NULL default '0', `bytes2` int(30) NOT NULL default '0', `emote_state` int(30) NOT NULL default '0', `npc_respawn_link` int(30) NOT NULL default '0', `channel_spell` int(30) NOT NULL default '0', `channel_target_sqlid` int(30) NOT NULL default '0', `channel_target_sqlid_creature` int(30) NOT NULL default '0', `standstate` int(10) NOT NULL default '0', PRIMARY KEY (`id`), KEY `b` (`map`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Spawn System' AUTO_INCREMENT=5575456 ;
Merci de m'aider,


Mamelouk

ViPHP
ViPHP | 3607 Messages

26 nov. 2008, 18:56

Quelque chsoe comme ça:

Code : Tout sélectionner

DELETE FROM creature_spawns where id IN (select id from creature_spawns group by position_x, position_y, position_z)