I think it would be much easier (and more efficient) if you did this all in one query, something like:
SELECT t1.id, t1.state, t1.subtime, t2.execw
FROM table1 t1
INNER JOIN table2 t2
ON t1.id = t2.id
WHERE t1.id = 23
ORDER BY t1.subtime DESC
LIMIT 1 # If you're expecting more than 1 record, remove this line
Then you can simply loop through the result set.