want insert a duplicate entry into mysql with a suffix. here is an example:
+-------+--------------+-------+
| ID | Title | url |
+-------+--------------+-------+
+-------+--------------+-------+
| 1 | test | test1 |
+-------+--------------+-------+
| 2 | test | test2 |
+-------+--------------+-------+
| 3 | test | test3 |
+-------+--------------+-------+
means, i want to add auto number as suffix to end of each url that have duplicate title. titles are duplicated but url are kinda unique.
Here is query:
$i = 0;
$i++;
$sql = "INSERT INTO `content` (title, text, cat, url, tag)
VALUES ('".$_POST["title"]."', '".$_POST["text"]."', '".$_POST["category"]."', '".$_POST["url"]."', '".$_POST["tag"]."') ON DUPLICATE KEY UPDATE url=".$_POST["url"]."+". $i ."";
note: url made dynamically based on title entry. this query not working, what is wrong with my code?
UPDATE: here is error after run query:
error: INSERT INTO
content
(title, text, cat, url, tag) VALUES ('test', '', '16', 'test', '') ON DUPLICATE KEY UPDATE url=test+1 Unknown column 'test' in 'field list'