Hi Is it possible to make a row(with number) increase every time the same value is added to the table? Example: I enter "test" into a table and it gets the following data: id=1 name=test count=1 And the next time I enter "test" into the table it becomes id=1 name=test count=2 instead of id=1 name=test count=1 id=2 name=test count=1 I want to create a form where users can suggest stuff and I want to see what is the most popular ect. Thanks in advance
In MySQL: Make the query similar to: INSERT INTO `table` (`id`, `name`, `count`) VALUES ($id, $name, 1) ON DUPLICATE KEY UPDATE `count`=`count`+1; Code (markup): So if the name inserted is new, then you start out with a single count. When multiple instances are created, it uses the duplicate key portion of the code and increments the count value instead.
This is a great solution. I used to query for a count and then either insert or update. This handles it all in one clean insert statement.