你看到这个 MySQL 查询有什么问题吗?它不执行。还有其他更好的想法吗?
INSERT INTO registration
( m_ID, e_ID, STATUS)
SELECT
:m_ID, :e_ID, 1
WHERE
EXISTS ( SELECT 1 FROM tableb WHERE ID = :e_ID)
AND EXISTS ( SELECT 1 FROM tablec WHERE m_ID = :m_ID)
e_id
传递带有和m_ID
(PDO)值的数组
基本上,目标是在插入另一个表之前检查两个 ID 是否存在于不同的表中。
错误:
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 'WHERE EXISTS ( SELECT 1 FROM tableb WHERE ID = '276') AND EX' at
line 4