php - INSERT IGNORE not work -


i try insert if not exists

so search , found:how 'insert if not exists' in mysql?

so try use ignore , table:

create table `users` ( `id` int not null auto_increment, `name` varchar(255), `mail` varchar(255), primary key (`id`) ) character set utf8 collate utf8_general_ci; 

and query:

insert ignore `users` set `mail` = ?, `name` = ? 

but insert if exists search , found: mysql insert ignore doesn't "ignore"

i read there primary key dosent insert duplicates

so can see in table have primary key
if problem need insert query id field problem because dont know when query
how insert information db without creating duplicates ?

insert ignore works when try insert value column primary key (id), haven't include id. on other hand don't need it. did right. when insert new user, it'll next available i'd, because it's auto_increment.

maybe want make email field uniq, 2 users can't have same email. in case insert ignore ignore adding new line if used email that's in table.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -