SQL error help

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 ?

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

Thanks Kisten, still 0 rows affected.

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

Oops my mistake. Snapshot had no records.

Good to have a reason :slight_smile: