+ 1

Are these 2 queries the same? (SQL)

1: SELECT * FROM tasks WHERE user_id = (SELECT id FROM users WHERE session_id = ?); 2: SELECT * FROM tasks INNER JOIN users ON tasks.user_id = users.id WHERE users.session_id = ?;

5th Aug 2021, 3:00 PM
Yahel
Yahel - avatar
2 Answers
0
SoloProg are there any preferences? In speed or whatever?
5th Aug 2021, 3:41 PM
Yahel
Yahel - avatar
0
from my experience, the preference would be the second query. it is easier to read and from what i remember joins are more efficient than sub queries.
5th Aug 2021, 4:35 PM
you are smart. you are brave.
you are smart. you are brave. - avatar