Jump to content

SQL check error


bookkc

Recommended Posts

this SELECT are not work

function OnLoginCheck(event, player)
local result = CharDBQuery("SELECT item_template FROM character_inventory WHERE `item_template` = '34470' AND `slot` = '12' AND `guid` = '"..player:GetAccountId().."';");
if (result) then
        player:SendBroadcastMessage("OOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKK")
    else
        player:SendBroadcastMessage("NNNNNNNNNNNNNNNNNNOOOOOOOOOOOOOOOOOOOO")
    end
end

RegisterPlayerEvent(3, OnLoginCheck)

why? i dont know, but if i delete this

 `item_template` = '34470' AND `slot` = '12' AND

  or this 

`guid` = '"..player:GetAccountId().."' 

this SQL Query are work fine, why  this 

WHERE `item_template` = '34470' AND `slot` = '12' AND `guid` = '"..player:GetAccountId().."';"

not work???

Edited by bookkc
Link to comment
Share on other sites

The issue is not related to Eluna in any way.

As you can see from the DB documentation: 

the guid is not account id. guid is the character guid from characters.
So your SQL query is wrong. Test your SQL with an SQL client to make sure it works properly.

 

Link to comment
Share on other sites

so, if i make this query

 

local result = CharDBQuery("SELECT item_template FROM character_inventory WHERE `guid` = '"..player:GetAccountId().."';");

all work fine... i think its not work with

AND

 

And this

 

 

guid int(11) unsigned

The GUID (Global Unique Identifier) of the character. [See character.guid].

why is GUID not character id??? wiki say that GUID is charatcer id

Edited by bookkc
Link to comment
Share on other sites

 

3 minutes ago, bookkc said:

so, if i make this query


local result = CharDBQuery("SELECT item_template FROM character_inventory WHERE `guid` = '"..player:GetAccountId().."';");

all work fine...

1

Just because your query matches some rows in the DB doesn't mean the query is correct. Like I said earlier, guid is not accountid so your query is wrong.
If you look at the data in your database you will likely see that the guid and accountid do not match for the rows you try to get from the database.

You could get the player guid from the player by using a function http://www.elunaengine.com/Object/GetGUIDLow.html
You could get the player guid through SQL joins from the character table through the accountid: https://www.w3schools.com/sql/sql_join.asp

Maybe you should not be using SQL at all. What is it exactly that you try to do here?
Are you trying to get an item from the player's inventory? There are many functions for it http://www.elunaengine.com/Global/RegisterPlayerEvent.html?search=getitemby

Link to comment
Share on other sites

Seems you edited your post and added a question that I did not see.
accountid is not characterid. account has multiple characters so accountid is separate from characterid. Characterid is actually character guid, which is lowguid.

characterid = guid in database = lowguid in core functions

 

And yes, you are right that it is characterid. But characterid is not accountid. Maybe this is the problem you have.

Link to comment
Share on other sites

  • 4 years later...

You cannot mention multiple column names with commas using ADD COLUMN. You need to mention ADD COLUMN every time you define a new column. You can utilize the SQL group by clause to organize identical data into groups. The group by single column function groups all entries that have the same value in only one column.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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