I have started learning SQL recently and I want to know about the difference between the 2 queries. Suppose I have a table "comments" which contains the fields: id, name, user_id and a table "users" which contains: id, name, rank
Code:
SELECT "comments" .*
FROM "comments" INNER JOIN "users" ON "users".id = "comments".user_id
WHERE "users".rank = 'admin'
Code:
SELECT "comments" .*
FROM "comments"
WHERE "comments".user_id IN (SELECT id
FROM users
WHERE "users".rank = 'admin');
In fact, I wonder if the making of a join does not load unnecessary fields but I also wonder if the making of a nested query is not a waste of time.
Bookmarks