Jump to content
  • 0

Search for an item on whole server


Question

Posted (edited)

Incase I want to see if the item for eg.icepick exists on the server and get his charid or accid

In which all tables can the item go?

inventory

cart_inventory

storage

mail

char

what will be sql query?

I turned up with something like this,

but it ain't working :|

SELECT c.char_id,c.account_id,c.name
FROM `char` c,`auction` a,`cart_inventory` ci,`guild_storage` g,`inventory` i,`mail` m,`storage` s
WHERE a.nameid=4035 OR ci.nameid=4035 OR g.nameid=4035 OR i.nameid=4035 OR s.nameid=4035;

Edited by Xtremist

6 answers to this question

Recommended Posts

Posted

This query should work fine for your case, just change 1201 for your item ID

select `account_id` from `char` where `char_id` in
(
select `char_id` from `inventory`  where `nameid`=1201
union
select `char_id` from `cart_inventory` where `nameid`=1201
)
or `account_id` in
(
select `account_id` from `storage` where `nameid`=1201
)
or `guild_id` in
(
select `guild_id` from `guild_storage` where `nameid`=1201
)

Posted (edited)

Yes I have tried my query on my own RO DB but population is low which is why I used knife[3] since they are the most common among newly created characters.

It returns the account ID if it finds the item specified.


select `account_id`, `char_id` from `char` where `char_id` in
(
select `char_id` from `inventory`  where `nameid`=1201
union
select `char_id` from `cart_inventory` where `nameid`=1201
union
select `dest_id` from `mail` where `nameid`=1201
)
or `account_id` in
(
select `account_id` from `storage` where `nameid`=1201
)
or `guild_id` in
(
select `guild_id` from `guild_storage` where `nameid`=1201
)

Edit: Noticed I forgot the mail check and returns the char_id.

Edited by JoWei
Posted

There a two more places, were items can be: auction and guild_storage.

Also it will be possible that cards are in equipment. I will check every table with a single query.

For example (inventory):

SELECT `char`.name, nameid, amount, refine, attribute, card0, card1, card2, card3
FROM `inventory` INNER JOIN `char` ON (`inventory`.char_id = `char`.char_id)
WHERE `nameid` = '/*[VARIABLE]*/' OR card0 = '/*[VARIABLE]*/' OR card1 = '/*[VARIABLE]*/'
OR card2 = '/*[VARIABLE]*/' OR card3 = '/*[VARIABLE]*/' ORDER BY `char`.`name` ASC

Replace /*[VARIABLE]*/ with the item-id.

Posted (edited)

There a two more places, were items can be: auction and guild_storage.

Also it will be possible that cards are in equipment. I will check every table with a single query.

For example (inventory):

SELECT `char`.name, nameid, amount, refine, attribute, card0, card1, card2, card3
FROM `inventory` INNER JOIN `char` ON (`inventory`.char_id = `char`.char_id)
WHERE `nameid` = '/*[VARIABLE]*/' OR card0 = '/*[VARIABLE]*/' OR card1 = '/*[VARIABLE]*/'
OR card2 = '/*[VARIABLE]*/' OR card3 = '/*[VARIABLE]*/' ORDER BY `char`.`name` ASC

Replace /*[VARIABLE]*/ with the item-id.

This is only for inventory :(

I want the whole thingy :) and in my post I have already added auction and guild storage.

Edited by Xtremist
Posted

Yes, it is an example. The other queries will be similar.

I did`t finish the complete script right now. It will show the items in the different places separatly, not all together. But you can show, where the items are.

My queries will show more informations about the owner and the item itself (refine, cards, etc.)

It was just an suggestion. Use the queries which more fits your desires. ^^

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...