参数化插入

时间:2017-07-10 16:48:58

标签: php mysql

如果table2上不存在值,我试图在table1中插入值。虽然我可以使用以下方法做到这一点:

INSERT INTO table1 (start, stop)
SELECT    a.*
FROM      (SELECT 123456789 start, 234567890 stop) a
LEFT JOIN table2 b ON (a.start,a.stop) IN ((b.start,b.stop))
WHERE     b.start IS NULL

您可以在此处查看示例https://stackoverflow.com/a/11998641/719554

我想使用PDO参数化123456789和234567890。我能做到吗?我以为我可以简单地执行以下操作

INSERT INTO table1 (start, stop)
SELECT    a.*
FROM      (SELECT :start AS start, :stop AS stop) a
LEFT JOIN table2 b ON (a.start,a.stop) IN ((b.start,b.stop))
WHERE     b.start IS NULL

0 个答案:

没有答案