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

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -