I am confused about this query where it uses insert statement and then ignore and then select. Can someone explain me this? Thanks
INSERT IGNORE INTO
myTable
SELECT
$var1 AS `CMMNCTID`,
$var2 AS `ENCID`,
variableID,
ProductID,
CustomerID,
Age,
"" AS `myJ`,
"" AS `myI`
FROM
table2
JOIN
table3
ON
table2.ID= table3.ID
The
SELECTis a subquery. What theINSERTis doing is inserting whatever is contained in the join oftable2andtable3, intomyTable. TheIGNOREtells it to ignore any entries for keys that already exist inmyTableand to just insert whatever doesn’t yet exist.It seems the purpose of the query is to combine the data that is associated between
table2andtable3and dump it intomyTable.