baziol1235
New Member
- Joined
- Sep 14, 2015
- Messages
- 10
- Reaction score
- 0
Hi guys, i've got some problem with this. I've found this solution :
It seems to be simple but it's not. I want to check if record with name='blabla' exisists in tabele offline_training , if it not exists it should create new record, if it exists it should update my column `timeLeft` with value 8 for example
this code doesn't work it, phpmyadmin says that it's "unrecognized statement type. (near IF)"
Of course i want put it to lua funciton if it will work fine.
This is error from phpmyadmin:
Code:
IF EXISTS (SELECT name FROM offline_training WHERE name='blabla')
UPDATE offline_training SET timeLeft=8 WHERE name='blabla'
ELSE
INSERT INTO offline_training (name) VALUES("blabla")
this code doesn't work it, phpmyadmin says that it's "unrecognized statement type. (near IF)"
Of course i want put it to lua funciton if it will work fine.
This is error from phpmyadmin:
Code:
Static analysis:
1 errors were found during analysis.
[LIST=1]
[*]Unrecognized statement type. (near "IF EXISTS" at position 0)
[/LIST]
Zapytanie SQL: [IMG]http://localhost:8080/phpmyadmin/themes/dot.gif[/IMG]
IF EXISTS (SELECT name FROM offline_training WHERE name='blabla') UPDATE offline_training SET `timeLeft`= 8 ELSE INSERT INTO offline_training (name) VALUES("blabla")
MySQL zwrócił komunikat: [IMG]http://localhost:8080/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 'UPDATE offline_training SET `timeLeft`= 8
ELSE
INSERT INTO offline_training ' at line 2
Last edited: