View Single Post
  #3  
Old 02-10-2015, 02:33 AM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default

Quote:
Originally Posted by Zaela_S View Post
http://www.w3schools.com/sql/sql_insert_into_select.asp

Don't fully understand what you're trying to do, but maybe something like:

Code:
INSERT INTO goallists (listid, entry)
SELECT 350, npc_types.id FROM npc_types
JOIN spawnentry ON npc_types.id = spawnentry.npcID
JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
WHERE zone = 'warrens' AND race = 455 AND name NOT LIKE '#%'

That nearly did it! So sometimes i want to make a task to kill any mob in a zone. So i used a goallist and added all the mobs. I wanted to have a sql script handle it. Or say a subset like Kill all skeletons.

EDIT:: the only reason that didn't work was i got a duplicate key value, but i see how the select 350, search works for the insert now thanks

EDIT::: is there a way to have it return only unique id / key values?

EDIT:::: This works perfectly and filters out doubles!

Code:
INSERT INTO goallists (listid, entry)
SELECT 350, npcid 
FROM npc_types
JOIN spawnentry ON npc_types.id = spawnentry.npcID
JOIN spawn2 ON spawnentry.spawngroupID = spawn2.spawngroupID
WHERE zone = 'warrens' AND race = 455 AND name NOT LIKE '#%'
group by npcid
Reply With Quote