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

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -