Jump to content
  • 0

help with an sql query


japtenks

Question

I'm trying to create a sql query string that will pull up the following querys, but will use variable so i only have to change one thing.

I'd like to set a variable that will store a string from the query

select distinct equipment_id from creature_template where entry in (select distinct id from creature 
where map=558);

results are 0,50,109,269,572,578,1522,1529

then feed that variable into this query

select * from creature_equip_template where entry in (0,50,109,269,572,578,1522,1529);
#select item ids
select equipentry1 from creature_equip_template where entry in (0,50,109,269,572,578,1522,1529)
union
select equipentry2 from creature_equip_template where entry in (0,50,109,269,572,578,1522,1529)
union
select equipentry3 from creature_equip_template where entry in (0,50,109,269,572,578,1522,1529);

results are 2178,5304,23906,13698,30310,28087,27836,0

then use the results of the 2nd query in

select entry,class,subclass,unk0,material,displayid,inventorytype,sheath from item_template 
where entry in (2178,5304,23906,13698,30310,28087,27836,0);

So far what I've googled and looked up has yet to yield any useful results, but other random good tidbits about mysql.

Thanks.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

The technique is called nested queries... i'm no expert on this, my boss is a dba so normally does things like this

hi,

you can write something like this:

select 
   entry,class,subclass,unk0,material,displayid,inventorytype,sheath 
from item_template 
where entry in (

  your nested select statment here

);

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use