I want to design a query where I want to fetch a name from a second table based on the id from the first table. I am able to get the result using the following two queries.
Please, Let me know which one is efficient or gives fast result and why.
SELECT r1.id, c1.categoryName
FROM request r1
LEFT JOIN category c1
ON r1.categoryId = c1.id
order by r1.dateCreated DESC;
SELECT id, (SELECT categoryName FROM category WHERE id
= categoryId)
FROM request r1
order by dateCreated DESC;