• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OF r

gmstrikker

Well-Known Member
Joined
Jul 30, 2014
Messages
458
Solutions
1
Reaction score
50
I need to run:
Code:
        CREATE TRIGGER `guilds_update`
            AFTER UPDATE OF rank_id ON players
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 );
        END;

To install a lib i found here on forum, but when i try, returns this error:
Code:
SQL query:




CREATE TRIGGER `guilds_update`
            AFTER UPDATE OF rank_id ON players
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 )





MySQL said: [IMG alt="Documentation"]http://localhost/phpmyadmin/themes/dot.gif[/IMG]

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OF rank_id ON players
       BEGIN
           UPDATE players
             ' at line 2

What should i do?
 
pheraps the parameter OF is not intended to do what you want

try to exequte this query
Code:
        CREATE TRIGGER `guilds_update`
            AFTER UPDATE ON players
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 );
        END;
and then try with
Code:
      AFTER UPDATE OF rank_id

instead of
Code:
      AFTER UPDATE ON players

when reading the title of the post it seems that this
'OF r
cannot be done by AFTER UPDATE, i searched that and found this
that confirm this
Code:
check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OF rank_id ON players
I dont know which statement has to be used to updated booth tables at the same time, players and rank_id but lets see what information we can get by doing this. Hope this helps somehow!
 
1
Code:
        CREATE TRIGGER `guilds_update`
            AFTER UPDATE ON players
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 );
        END;

Code:
Error
SQL query: [IMG alt="Documentation"]http://localhost/phpmyadmin/themes/dot.gif[/IMG]




CREATE TRIGGER `guilds_update`
            AFTER UPDATE ON players
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 )





MySQL said: [IMG alt="Documentation"]http://localhost/phpmyadmin/themes/dot.gif[/IMG]

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BEGIN
           UPDATE players
              SET guild_id = IFNULL( (
   ' at line 3


2
Code:
        CREATE TRIGGER `guilds_update`
            AFTER UPDATE OF rank_id
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 );
        END;

Code:
SQL query: [IMG alt="Documentation"]http://localhost/phpmyadmin/themes/dot.gif[/IMG]




CREATE TRIGGER `guilds_update`
            AFTER UPDATE OF rank_id
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 )





MySQL said: [IMG alt="Documentation"]http://localhost/phpmyadmin/themes/dot.gif[/IMG]

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'OF rank_id
       BEGIN
           UPDATE players
              SET guild_' at line 2
 
Code:
CREATE TRIGGER `guilds_update`
            AFTER UPDATE ON players
        BEGIN
            UPDATE players
               SET guild_id = IFNULL( (
                       SELECT guild_id
                         FROM guild_ranks
                        WHERE id = rank_id
                   )
                   , 0 )





MySQL said: [IMG alt="Documentation"]http://localhost/phpmyadmin/themes/dot.gif[/IMG]

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'BEGIN
           UPDATE players
              SET guild_id = IFNULL( (
   ' at line 3

Ok this give us more information, now we need to see what is the right syntax to use near 'BEGIN. To start solving this I'm lack of time, but I searched some usefull links:

Using WHERE

CREATING DIFFERENT TRIGGERS

MAKING AFTER UPDATE TRIGGERS

USING DIFFERENT KIND OF QUERIES

Reading stuff like that can give you ideas of what you need to try, some examples could be:

Code:
CREATE TRIGGER `guilds_update`
AFTER UPDATE ON `players` WHERE `rank_id`<> 1;
BEGIN

or something like
Code:
AFTER UPDATE
SELECT `rank_id` FROM `players`

and reading the errors that appears after the running the query, will guide you to the source of the problem (with some google search ofc)

I've never studied much of this, the only experience I had with MySQL are OTServers, but I guess this information could help you. Good luck with it, i'll do more research to see if we can get it to work, regards!
 
Back
Top