SQL: INSERT, Update if not exist

astralprojection

New member
Messages
334
Points
0
@AnnieRuru i was trying to make some mod on your script VIP SYSTEM. I want to prevent inserting new record for  same char_id each time it expire and avail again. The query_sql seems not update the record. thanks :D

Code:
CREATE TABLE `vip_system` (
 `char_id` int(11) unsigned NOT NULL,
 `start_time` datetime DEFAULT NULL,
 `end_time` datetime DEFAULT NULL,
 PRIMARY KEY (`char_id`),
 UNIQUE KEY `char_id` (`char_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
Code:
query_sql "INSERT INTO `vip_system` VALUES ("+ getcharid(CHAR_ID_CHAR) +", NOW(), DATE_ADD(NOW(), INTERVAL "+ 1 +" WEEK)) ON DUPLICATE KEY UPDATE `char_id` = "+getcharid(CHAR_ID_CHAR);
 
Back
Top