skript-db issue with variables

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

mbgl

New Member
Nov 15, 2025
5
0
1
Hey, I have an issue with Minecraft Skript and skript-db.

Addons: skript-db, TuSKe, skRayFall (maybe unimportant)
Version:
Server: 1.12.2
Skript: 1.6.4
Server Software: Mohist

When i want to pharse an variable in an sql execute statement, it is not working.

Example:

WORKING:
command /test:
trigger:
set {_p} to player
execute unsafe "SELECT u.rank FROM users u WHERE player = '%player%' ;" in {-sql} and store the result in {_s::*}
broadcast "test %{_s::rank::1}%"

NOT WORKING:
command /test2:
trigger:
set {_p} to player
execute unsafe "SELECT u.rank FROM users u WHERE player = '%{_p}%' ;" in {-sql} and store the result in {_s::*}
broadcast "test %{_s::rank::1}%"

Things like following are also not working:
execute unsafe "SELECT u.rank FROM users u WHERE player = %{_p}% ;" in {-sql} and store the result in {_s::*}
execute unsafe "SELECT u.rank FROM users u WHERE player = '{_p}' ;" in {-sql} and store the result in {_s::*}
execute unsafe "SELECT u.rank FROM users u WHERE player = {_p} ;" in {-sql} and store the result in {_s::*}
execute unsafe "SELECT u.rank FROM users u WHERE player = '" and {_p} and "' ;" in {-sql} and store the result in {_s::*}
execute unsafe "SELECT u.rank FROM users u WHERE player = '" + {_p} + "' ;" in {-sql} and store the result in {_s::*}

Thanks in forward for helping!
 
So i actually got a solution, i'm not happy with it, but it is working.

Code:
function getRank(p: player) :: text:
    set {p} to {_p}
    execute unsafe "SELECT u.rank FROM users u WHERE player like '%{p}%' ;" in {-sql} and store the result in {_s::*}
    wait 1 tick
    return "%{_s::rank::1}%"

So the problem was, that the {_p} inside wasn't converted and it sends litterlary as %{_p}% to the Database.

I think it is because the server "waits" until the action is finished, so it clears the {_p}, with a permanent variable {p} it works.

I'm looking for another solution, but i'm unsure if there is a better.