I’m trying to create a page view for a project I’m working on and I can’t
seem figure out the MySQL statement. Any assistent you can provide would be greatly appreciated.
I have 2 critaries:
IP address (db field: unique)
Project ID
The script itself works if I take out the when clause. It updates the IPaddres field if not updates the count field.
What I’m looking for:
If a record meets the criataria (projectID & IPaddress) increment the count field. (returning user viewing the same project)
else
update the table with projectID, IPaddress and increment the count field ( this could be a new user or a returning user whos viewing a different project)
You asked the same question on another post for table information but I wasn’t able to give that information due my MYSQL knowledge but this time you provided the know how thanks.
as per the make up of the table:
tbl_testTB
CREATE TABLE `tbl_testTB` (
`test_index` int(11) NOT NULL AUTO_INCREMENT,
`test_prjID` int(11) NOT NULL,
`test_historyDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`test_visitedIP` varchar(100) NOT NULL,
`test_count` int(11) NOT NULL,
PRIMARY KEY (`test_index`),
UNIQUE KEY `test_visitedIP` (`test_visitedIP`),
UNIQUE KEY `test_visitedIP_2` (`test_visitedIP`),
UNIQUE KEY `test_prjID` (`test_prjID`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4