Well, I trying insert into tables to another but I get this error;
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''lcl_user_agent' (user_agent, hitcount, click_timestap) SELECT visite_useragent,' at line 1]
This is my code;
$addagent = "INSERT INTO $wpdb->prefix.'lcl_user_agent' (user_agent, hitcount, click_timestap) SELECT visite_useragent, visite_hitcount, click_timestap FROM $wpdb->prefix.'lcl_visite_agent' .agent_id IN (' . $agent_id . ')"; $wpdb->query($addagent);
I want insert into lcl_user_agent the visites from visite_useragent then I get the visite for block with $agent_id
from the form
Advertisement
Answer
It looks like you’re messing up at the very end. It should be this form:
INSERT INTO table2 (column1, column2, column3, ...) SELECT column1, column2, column3, ... FROM table1 WHERE condition;
So maybe this is what you’re going for?
$addagent = ' INSERT INTO '.$wpdb->prefix.'lcl_user_agent (user_agent, hitcount, click_timestap) SELECT visite_useragent, visite_hitcount, click_timestap FROM '.$wpdb->prefix.'lcl_visite_agent WHERE agent_id IN (' . $agent_id . ') ';