Usa COALESCE
invece:
SELECT
e.id,
c.name,
e.location,
e.designation,
e.time_period_from,
e.time_period_to,
DATEDIFF(COALESCE(e.time_period_to, NOW()), e.time_period_from) AS tenure_in_days
FROM employment e
LEFT JOIN company c ON (c.id = e.company_id)
LIMIT 0, 10
Immagino tu voglia DATEDIFF(e.time_period_to, e.time_period_from)
.
Usando LIMIT
senza esplicito ORDER BY
può restituire il risultato in base al piano di esecuzione.