Fix subquery insert for sqlite3