mardi 27 août 2019

mysql use variable to decide if to execute insert

I have a table that must have only one row. if this row exist don't do nothing if there is no row insert data that does NOT contain the indexs field

i tried to use the below code but i get arror

select count(id) into @myvar from customer; IF(@myvar>0) BEGIN INSERT INTO customer (dateformat, alarmDays, backup, pastPass, loginFails, passLength, timetochangepass) values('d,m,y',30, 30, 3, 5, 8, 90) END

Aucun commentaire:

Enregistrer un commentaire