mysql - sql if not exists () insert not working -
this query:
if not exists (select * teovecerdi locationname = 'frankfurt' , startdate = '14/02/2015' , enddate = '17/02/2015' , price = '2700') insert teovecerdi(locationname, startdate, enddate, price) values(?,?,?,?) can tell me what's wrong it? i've tried begin , end , still gives me error.
edit: handle parameters correctly.
you can't use if statement in query, can used in stored procedure.
if want conditional insert, can use select query returns row when condition met.
insert teovecerdi(locationname, startdate, enddate, price) select ?, ?, ?, ? dual not exists (select * teovecerdi locationname = 'frankfurt' , startdate = '14/02/2015' , enddate = '17/02/2015' , price = '2700')
Comments
Post a Comment