SQLite Forum

I need a little help with UPDATE?
Login
> Note that this will replace ALL station names in t1 with whatever they are in "s" for the same lat-long

and any location not found will have the station name set to null.

Either of the following will fix that (assuming that you do not want not found station names set to null.

```
UPDATE t1
   SET start_station_name = coalesce((SELECT s.start_station_name
                                        FROM s
                                       WHERE start_lat = t1.start_lat
                                         AND start_lng = t1.start_lng
                                     ), start_station_name)
;
-- or --
UPDATE t1
   SET start_station_name = s.start_station_name
  FROM s
 WHERE s.start_lat = t1.start_lat
   AND s.start_lng = t1.start_lng
;
```