Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.
Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin. Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

mysql so'rovda shart bilan o'zgartirish kiritish

+1 ovoz
98 marta ko‘rilgan
so‘radi 23 dekabr, 18 parmonov98 (1,684 bal)
tahrirlandi 24 dekabr, 18 parmonov98

IF EXISTS(SELECT * FROM s_table as s WHERE s.senid = '2' AND s.u_id = '1' )

THEN

BEGIN

UPDATE s_table

SET correct = (`correct` + 1)

WHERE s_table.senid = '2' AND s_table.u_id = '1'

END;

BEGIN

ELSE

INSERT INTO s_table (senid, s_table.u_id, correct, incorrect)

VALUES (3, 2, 1, 0);

END;

qaytarayotgan error: 

mysql 5.7 talqinida

Error

Static analysis:

1 errors were found during analysis.

  1. Unrecognized statement type. (near "IF EXISTS" at position 0)

SQL query:Documentation

IF EXISTS(SELECT * FROM s_table as s WHERE s.senid = '2' AND s.u_id = '1' ) THEN BEGIN UPDATE s_table SET correct = (`correct` + 1) WHERE s_table.senid = '2' AND s_table.u_id = '1' END

MySQL said:Documentation

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF EXISTS(SELECT * FROM s_table as s WHERE s.senid = '2' AND s.u_id = '1' )
   ' at line 1 

Bu xatolikka sabab nima? mysql 5.7 talqinda ishlayapti.

izoh qoldirdi 23 dekabr, 18 Saidolim (3,566 bal)
Savolni to`g`rilab yuboring. Umuman tushunarsiz bo`lib qolibdi
izoh qoldirdi 25 dekabr, 18 Jasur320 (87 bal)
ko‘rsatildi 26 dekabr, 18 Kenjebaev
5.7 versiyada yangi kiritilgan bu "IF EXISTS", eskilarida yo'q.

1 ta javob

0 ovoz
javob berdi 02 yanvar, 19 Kenjebaev (1,092 bal)
 
Eng yaxshi javob
MySQL ning eski versiyalarida bunday qilib bo'lmaydi, 5.7 versiyadan boshlab qo'llash mumkin

Assalomu alaykum, yordam.uz saytimizga xush kelibsiz.

Bu saytda o`zingizni qiziqtirgan savollarga javob olishingiz va o`z sohangiz bo`yicha savollarga javob berishingiz mumkin.

Bizning Oilamizga a'zo bo`lganingiz uchun chuqur Minnatdorchilik bildiramiz !!!

Telegram kanal YordamUzRss

...