我正在尝试使用以下内容执行插入:
INSERT INTO stock_withholds (s_id, mob, paddock, product, completed_date, withhold_until_date, ESI_withhold_until_date)
SELECT stk_id AS s_id,
mob,
paddock,
product,
completed_date,
withhold_until_date,
ESI_withhold_until_date
FROM stock_current
WHERE (withhold_until_date >=CURDATE()
OR (ESI_withhold_until_date >= CURDATE()
AND stock_current.stk_id NOT IN
(SELECT s_id
FROM stock_withholds)
如果我重新运行查询,它会复制记录。
如果withhold_until_date或ESI_withhold_until_date大于插入记录的当前日期,则需要的结果。
谢谢