使用或使用选择插入

时间:2018-06-18 13:26:09

标签: mysql

我正在尝试使用以下内容执行插入:

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大于插入记录的当前日期,则需要的结果。

谢谢

0 个答案:

没有答案