My columns are like this. column "a" is primary and auto incremantal.
a | b | x | y
(2, "example.com" , "admin", "123456")
(3, "example.com" , "user", "123456")
(4, "example2.com" , "admin", "123456")
(5, "example.com" , "admin", "5555555")
You want to let the database do the work. Although you can set up a condition within a query, that condition may not be universally true or someone might use another query.
The database can check this with a unique constraint or index. Actually, the unique constraint is implementing using a unique index:
create unique index unq_t_b_x on t(b, x);
(The columns can be in either order.)
The insert would then look like:
insert into t(b, x, y) values ('example.com', 'admin', '5555555') on duplicate key update b = values(b);
Note that the auto-incremented value is not included in the update.
on duplicate key update just prevents the
insert from generating an error. It is better than
insert ignore because the latter will ignore all errors, and you just want to ignore the one caused by the duplicate key.