如果我只是瞎了,我觉得这没有任何意义,因为我总是像这样写它而且我看到它有什么问题。除了我在语法中使用了多个SQL解决方案仍有错误...
我的PHP代码:
$sql1 = " SELECT table1.file_name, table2.path
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON t1.file_name = t2.path
WHERE t2.path IS NULL OR t1.file_name <> t2.file_name OR t1.file_name <> t2.path";
$sql2 = "INSERT INTO table3 (file_name) VALUES(".$sql1.")";
Shopware()->Db()->query($sql2);
我的错误讯息:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT table1.file_name, table2.path FROM (the first 2 letters of table1)' at line 1 in Zend\Db\Statement\Pdo.php on line 234
答案 0 :(得分:3)
INSERT INTO ... SELECT ... FROM ...;
不为INSERT INTO ... VALUES (SELECT ... FROM ...);
。