I have an insert that looks like this (using MySQL)
INSERT INTO user_actions(action_id,user_id,action_type,record_id,on_table) VALUES
(
action_id,
'1',
'1',
'32',
'1'
)
ON DUPLICATE KEY UPDATE
user_id=user_id AND
action_type = action_type AND
record_id = record_id AND
on_table = on_table
and action_id
is AUTO_INCREMENT
The objective si to insert into the table, only if certain values are different.
What is my mistake??
And second, could i do an IF, ELSE with an select? like
var_count = count
(
SELECT action_id FROM user_actions
WHERE
action_id = 'value' AND
user_id 'value' AND
action_type 'value'
record_id 'value' AND
on_table 'value' AND
)
IF var_count = 0
INSERT INTO user_actions(action_id,user_id,action_type,record_id,on_table) VALUES
(
action_id,
'1',
'1',
'32',
'1'
)
ELSE
... echo error
END IF