Reputation: 292
I have:
INSERT INTO ItemTracking(`Item`, `Source`, `LeftSourceAt`)
SELECT `Item`, `Source`, now() FROM ItemAvailability WHERE Item = 'PA';
I want to execute the above query ONLY IF ItemBeingTracked
in ItemAvailability
is NULL
.
Edit: If ItemAvailability.ItemBeingTracked == NULL Then
do the above query.
Upvotes: 1
Views: 41
Reputation: 56499
a bit rusty with SQL, but I believe this is one way to go about it.
INSERT INTO ItemTracking(`Item`, `Source`, `LeftSourceAt`)
SELECT `Item`, `Source`, now()
FROM ItemAvailability
WHERE Item = 'PA' AND ItemBeingTracked IS NULL;
Upvotes: 1
Reputation: 1271231
I think you would just add the condition to the WHERE
:
INSERT INTO ItemTracking(Item, `Source`, LeftSourceAt)
SELECT Item, `Source`, now()
FROM ItemAvailability
WHERE Item = 'PA' AND ItemBeingTracked IS NULL;
Upvotes: 2