I have the following query: Code:
UPDATE STAYSPEC SET date_out = CASE WHEN EXISTS (SELECT * FROM STAYSPEC AS STAYSPEC2 WHERE (STAYSPEC2.STAYNUM = STAYSPEC.STAYNUM) AND (STAYSPEC2.ORDER_SPEC = STAYSPEC.ORDER_SPEC+1)) THEN (SELECT date_in FROM STAYSPEC AS STAYSPEC3 WHERE (STAYSPEC3.STAYNUM = STAYSPEC.STAYNUM) AND (STAYSPEC3.ORDER_SPEC = STAYSPEC.ORDER_SPEC+1)) ELSE (SELECT STAYHOSP.date_out FROM STAYHOSP WHERE (STAYHOSP.STAYNUM = STAYSPEC.STAYNUM)) END; date_in and date_out have both the type TEXT. So I need, for every record in STAYSPEC, to find another record in STAYSPEC that has the same STAYNUM field and an ORDER_SPEC field that is 1 more. I want to replace the date_out from STAYSPEC with that date (in text format). If such a record does not exist (EXISTS) then it needs to take the date_out from the STAYHOSP table where the STAYNUM is the same. Whenever I execute the above query it doesn't give an error or something, it's just keeps running without ever stopping ! Since it's quite hard to debug this I sincerely hope someone can help me with this. -- View this message in context: http://old.nabble.com/UPDATE-question-tp32673794p32673794.html Sent from the SQLite mailing list archive at Nabble.com. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users