Gideon
February 18, 2017, 10:34am
1
Why is this sql statement returning no results. I am stumped.
UPDATE Snapshot
SET gelewer_h = i.lewering,
klaar = i.klaar
FROM (
SELECT plaasno,blokno,lewering,klaar
FROM LeweringVsSkatting) i
WHERE
i.plaasno = snapshot.plaasno
and
i.blokno = snapshot.blokno
Anyone can spot what I am missing ?
Kristen
February 18, 2017, 10:41am
2
I don't think it will be any different, but I would have written the query like this:
UPDATE U
SET gelewer_h = i.lewering,
klaar = i.klaar
FROM Snapshot AS U
JOIN LeweringVsSkatting AS i
ON i.plaasno = U.plaasno
and i.blokno = U.blokno
Gideon
February 18, 2017, 10:49am
3
Thanks Kisten, still 0 rows affected.
Kristen
February 18, 2017, 1:09pm
4
Presumably this gives 0 rows then:
SELECT COUNT(*)
FROM Snapshot AS U
JOIN LeweringVsSkatting AS i
ON i.plaasno = U.plaasno
and i.blokno = U.blokno
if so you need to find the rows that you were expecting to be updated and then figure out why they were not included in that query
Gideon
February 19, 2017, 12:06pm
5
Oops my mistake. Snapshot had no records.