Hello guys,
I’m trying to build a query that adds a user’s check in / out date and time in to the database, basically I need to check if 5 columns match if so update the row, if not add a new row. I thought this was going to be easy but after a few hours of reading, I am still not able to get the query to work *sigh*
This is how my table is built:
CREATE TABLE `conferences_seminar_sessions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userid` int(11) NOT NULL,
`eventid` int(11) NOT NULL,
`theaterid` int(11) NOT NULL,
`seminarid` int(11) NOT NULL,
`action` tinyint(1) NOT NULL,
`created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
And this is my query:
$query = "
INSERT INTO cswconferences_seminar_sessions
(userid, eventid, theaterid, seminarid, action)
VALUES ('" . $userid . "', '" . $eventid . "', '" . $theaterid . "', '" . $seminarid . "', '" . $action . "')
ON DUPLICATE KEY UPDATE userid=userid+'" . $userid . "'
AND eventid=eventid+'" . $eventid . "'
AND theaterid=theaterid+'" . $theaterid . "'
AND seminarid=seminarid+'" . $seminarid . "'
AND action=action+'" . $action . "'
;";