I am using two sub-queries to fetch log_msg
and log_state
from the same table.
I want to ask how can I convert these 2 sub queries into a single sub query so that I don't need to make call to the same table twice.
SELECT t1.objectId, t1.name,
(SELECT a.logs FROM logTable a WHERE a.logId = t1.logId ORDER BY id DESC LIMIT 1) AS log_msg,
(SELECT a.state FROM logTable a WHERE a.logId = t1.logId ORDER BY id DESC LIMIT 1) AS log_state,
FROM table1 t1 WHERE t1.CreateDate >= '2019-12-01';