sql - if in mysql insert statement -
i kind of thing:
if ((19, 13) not in (select idutente, idlezione partecipa)) insert partecipa (idutente, idlezione, idabbonamento, utente, prova, riserva) values( 19, 13, (select idabbonamento abbonamento attivo=1 , idutente=19), (select concat(u.nome," ",u.cognome) abbonamento a, utente u a.attivo=1 , a.idutente=u.idutente , u.idutente=19), 0, 0) end if;
but there error in syntax
error code: 1064. have error in sql syntax; check manual corresponds mysql server version right syntax utilize near 'if ((19, 13) not in (select idutente, idlezione partecipa)) insert int' @ line 1 0.000 sec
and on net can't find solution. can help me?
try this:
insert partecipa (idutente, idlezione, idabbonamento, utente, prova, riserva) select 19, 13, ab.idabbonamento, concat(u.nome, ' ', u.cognome), 0, 0 abbonamento ab inner bring together abbonamento on ab.attivo = a.attivo , ab.idutente = a.idutente inner bring together utente u on a.idutente = u.idutente a.attivo = 1 , u.idutente = 19 , not exists(select 1 partecipa idutente = 19 , idlezione = 13);
mysql sql syntax-error
No comments:
Post a Comment