View Single Post
  #1  
Old 02-10-2015, 01:26 AM
Bohbo
Hill Giant
 
Join Date: Dec 2012
Posts: 116
Default 3 failed SQL Attempts to insert a value + a select statement result

I am trying to take a task ID using 350 in this example. And based on a select criteria in this case looking at whether or not a mob is non named, race 455, in warrens.

So the idea is you can test this with a select * from npc_types to test your selection statement. Once you have that correct take the list of IDs select id from npc_types and insert that + fixed value of 350 into the goal lists table.

Any tips here to get any of the methods working would be appreciated. I feel like its a good teachable moment through my 3 examples of failure.

Code:
foreach(SELECT id 
FROM npc_types 
      inner join spawnentry on npc_types.id = spawnentry.npcID 
		inner join spawn2 on spawnentry.spawngroupID = spawn2.spawngroupID
		where zone = 'warrens' and race = 455 and name not like '#%'
		, 
		insert into goallists (listid, entry)		
		values (350,id))
Code:
insert into goallists (listid, entry)

set @goalid=
SELECT id 
FROM npc_types 
      inner join spawnentry on npc_types.id = spawnentry.npcID 
		inner join spawn2 on spawnentry.spawngroupID = spawn2.spawngroupID
		where zone = 'warrens' and race = 455 and name not like '#%'
insert into goallists (listid, entry)		
values (350,@goalid)

Code:
insert into goallists (listid, entry)

SELECT id 
FROM npc_types 
      inner join spawnentry on npc_types.id = spawnentry.npcID 
		inner join spawn2 on spawnentry.spawngroupID = spawn2.spawngroupID
		where zone = 'warrens' and race = 455 and name not like '#%'
		
values (350,id)
Reply With Quote