I will like to insert into same table if the ip_address for the product_id wasn't exist but preferably not to create two separate query. How can I achieve it?
Below will be the sample table:
id | product_id | ip_address |
------------------------------
a 11112 8.8.8.8
b 11234 9.9.9.9
and my code is something like this but it doesn't work.
INSERT INTO `'._DB_PREFIX_.'views`
(SELECT '.$id_product.',"'.$ip_addr.'"
FROM `'._DB_PREFIX_.'views`
WHERE NOT EXISTS (SELECT * FROM
`'._DB_PREFIX_.'views` v WHERE v.id_product ='.$id_product.' AND
t.ip_address ="'.$ip_addr.'"
))'