Jump to content
  • 0

SQL Query with exact match


Elijah23

Question


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  292
  • Reputation:   17
  • Joined:  12/12/11
  • Last Seen:  

Hello everyone, just wanted to know on how to do this in game.. :)

Don't know if this belongs here or in the scripting section, sorry if I'm wrong..

I have an npc which looks for the guild id of a specific guild which will be an input in the npc..

I have use this sql query and its working:

query_sql "SELECT `guild_id` FROM `guild` WHERE `name` = '"+@guild_name$+"'",@type_id;

The problem is, I want the name to be exact.

For example,

I was looking for the guild id of test, and I have input in the npc test123. It would still be able to get the ID of test guild but instead I want the npc to input it as not existing since there is really a no guild name of test123 and it should be test only.

Another example again for guild test,

If I input tes only, It would still be able to get the ID of test guild but instead I want the npc to input it as not existing since there is really a no guild name of tes and it should be test.

So what I am aiming is a sql query with an exact match of the input..

I have searched in google how to do this and find this:

add % before and after the string and use LIKE

Example:

query_sql "SELECT `guild_id` FROM `guild` WHERE `name` LIKE ' %guild_name% ' "

But I can't integrate it with the script:

query_sql "SELECT `guild_id` FROM `guild` WHERE `name` LIKE ' "+%@guild_name$%+"' ",@type_id;

or

query_sql "SELECT `guild_id` FROM `guild` WHERE `name` LIKE '%"+@guild_name$+"%' ",@type_id;

Doesn't work for me.. xD

So if anyone knows how to do what I wanted to do, please share it to me.. xD

Advance thanks!.. :)

Edited by wakoko321
Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

query_sql "SELECT `guild_id` FROM `guild` WHERE `name` LIKE '%"+@guild_name$+"%' ",@type_id;

^ this one should work.

The SQL query would be like this:

SELECT guild_id FROM guild WHERE `name` LIKE '%test%';

So the code in a script:

query_sql "SELECT guild_id FROM guild WHERE `name` LIKE '%" + .@guild_name$ + "%'", .@guild_id;

Link to comment
Share on other sites

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.

×
×
  • Create New...