我有:
INSERT INTO ItemTracking(`Item`, `Source`, `LeftSourceAt`)
SELECT `Item`, `Source`, now() FROM ItemAvailability WHERE Item = 'PA';
我想在ItemBeingTracked
ItemAvailability
中执行上述查询仅 NULL
。
修改:If ItemAvailability.ItemBeingTracked == NULL Then
执行上述查询。
答案 0 :(得分:2)
我认为您只需将条件添加到WHERE
:
INSERT INTO ItemTracking(Item, `Source`, LeftSourceAt)
SELECT Item, `Source`, now()
FROM ItemAvailability
WHERE Item = 'PA' AND ItemBeingTracked IS NULL;
答案 1 :(得分:1)
SQL有点生疏,但我相信这是一种解决方法。
INSERT INTO ItemTracking(`Item`, `Source`, `LeftSourceAt`)
SELECT `Item`, `Source`, now()
FROM ItemAvailability
WHERE Item = 'PA' AND ItemBeingTracked IS NULL;