On 10/24/2013 9:17 PM, David Bicking wrote:
You could try
REPLACE LEAGUEPLAYERS (playerid, leaqueid, original_rank, current_rank)
  SELECT L.playerid, L.leagueid, P.rank, P.rank
  FROM leagueplayers L INNER JOIN players P ON L.playerid = P.playerid;

REPLACE (which is a shorthand for INSERT OR REPLACE) only replaces when insertion would violate some uniqueness constraint. But there are no such constraints on leagueplayers. Your statement would insert a bunch of new rows, leaving the original ones unmodified.

But I think sqlite would notice that the subquery was the same in the
UPDATE statement that Igor T gave and not run it twice

I don't believe SQLite is quite that smart. It wasn't last time I checked. I think it will, too, run the subquery twice, but since it uses an index, that should be reasonably fast.
--
Igor Tandetnik

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to