Problem with WHERE NOT EXISTS #18

Closed
opened 2022-04-28 06:13:25 +00:00 by Padsou · 4 comments

Hi

I'm in spigot 1.18.1 and the last version of skript-db

I want that when a player connects to the server it adds him to the database if he doesn't already exist.

I tried the following command but it doesn't work, it tells me that I have an error on my WHERE NOT EXISTS

The INSERT INTO part works perfectly

2022-04-28_08.10.51

execute "INSERT INTO player (name,uuid,grade) VALUES (%name of player%,%uuid of player%,%{grade.info.%player%}%) WHERE NOT EXISTS ( SELECT uuid,name FROM player WHERE name=%name of player% AND uuid=%uuid of player% )" in {sql}

Does anyone have an idea how to solve the problem?

Hi I'm in spigot 1.18.1 and the last version of skript-db I want that when a player connects to the server it adds him to the database if he doesn't already exist. I tried the following command but it doesn't work, it tells me that I have an error on my WHERE NOT EXISTS The INSERT INTO part works perfectly ![2022-04-28_08.10.51](/attachments/124bbc3e-73ca-44b4-9164-b09be63c0520) ```SQL execute "INSERT INTO player (name,uuid,grade) VALUES (%name of player%,%uuid of player%,%{grade.info.%player%}%) WHERE NOT EXISTS ( SELECT uuid,name FROM player WHERE name=%name of player% AND uuid=%uuid of player% )" in {sql} ``` Does anyone have an idea how to solve the problem?
Owner

you don't need where not exist in insert, just create unique key on uuid, then insert will fail if it already exists

you don't need where not exist in insert, just create unique key on uuid, then insert will fail if it already exists
Author

Ok, how can I do this with skript-db?

Ok, how can I do this with skript-db?
Owner

it's not a skript-db feature, it's SQL feature, it's in your table structure

it's not a skript-db feature, it's SQL feature, it's in your table structure
Author

Ok this work, thanx you for your ansmwer :)

Ok this work, thanx you for your ansmwer :)
Govindas added the
question
label 2022-04-28 17:53:34 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Limework/skript-db#18
No description provided.