What do I need for SELECTin a subquery WHERE EXIST?
Here is a random request sentence WHERE EXIST:
SELECT a.*
FROM a
WHERE EXISTS
(SELECT *
FROM b
WHERE b.a_id = a.id)
So, *selected in b. But this makes no sense to me, because I do not want to choose anything (if I did not understand the behavior WHERE EXIST). I could choose 1, but that also seems strange.
I think that it doesn’t really matter in terms of speed of execution, and it could work, but it could matter in terms of readability and "semantics." (I'm not sure about the words I use!). Is there any best practice for this? If so, why is one method chosen over another?
source
share