mysql - "if not exists" SQL Statement Giving Error -
this question has answer here:
- mysql: insert record if not exists in table 15 answers
i have following sql query running , giving me error 1064, syntax error.
if not exists (select * locations street_address = 'test') begin insert locations (street_address) values ('test') end;
can please me out? seems simple yet not run. thanks.
also, i'm running mysql version 5.6.11
also can try this
insert locations (street_address) select 'test' dual not exists ( select * locations street_address = 'test' ) limit 1;
Comments
Post a Comment