0

My table (name is primary key, id is unique key):

||   name   || id ||    col_1    ||
===================================
||  test1   ||1234||   test999   ||

Query:

REPLACE INTO `table` (`name`, `col_1`) VALUES ('NOTTEST1', 'test999').

In this case, it mustn't replace row, but it does. What am I doing wrong?

Sven-Michael Stübe
  • 14,560
  • 4
  • 52
  • 103
Nitor
  • 401
  • 1
  • 4
  • 8

1 Answers1

0

It works well!

can you check if table structure is set correctly. Here's what I did:

Table:

CREATE TABLE `test` (
  `name` varchar(25) NOT NULL,
  `id` int(11) DEFAULT NULL,
  `col_1` varchar(25) DEFAULT NULL,
  PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

insert  into `test`(`name`,`id`,`col_1`) values ('test1',1234,'test999');

And when I tried this:

REPLACE INTO test (`name`,`col_1`) VALUES('test11','admin');

It created a new record.

Lucky Chingi
  • 2,248
  • 1
  • 10
  • 15