Yapmak istediğim eğer veri yoksa oluşturmak, eğer varsa onu güncellemek.
Ama hata veriyor nasıl olacak? Bir fikri olan var mı?
SQL:
if exists (select kisi from sayac_rapor where webid='toplam_sayac' and tarih='2007-05-07' limit 1)
update sayac_rapor set kisi=(kisi+1) where webid='toplam_sayac' and tarih='2007-05-07' limit 1;
else
insert into sayac_rapor values(NULL,'toplam_sayac','2007-05-07','1');
phpMyAdmin'de test ettiğimdeki hata:
SQL sorgusu:
IF EXISTS ( SELECT kisi
FROM sayac_rapor
WHERE webid = 'toplam_sayac'
AND tarih = '2007-05-07'
LIMIT 1
)
UPDATE sayac_rapor SET kisi = ( kisi +1 ) WHERE webid = 'toplam_sayac' AND tarih = '2007-05-07' LIMIT 1 ;
MySQL çıktısı:
#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 kisi from sayac_rapor where webid='toplam_sayac' and tarih='20' at line 1
Saygılar.