Powered by Blogger.

How to avoid duplicate entry without having primary and unique key in the table in mysql?



INSERT INTO `table_name` (`name`, `label`, `description`)
select * from
    (select 'my_name', 'My Name', 'Its Me') as tmp
where not exists (
    select `name` from `table_name` where `name` = 'my_name'
) limit 1;

No comments