No you wouldn't, because in the first part you are retrieving all cliente
s where the cliente
's id is the queried id (ID_CLIENTE = @ID_CLIENTE
), whereas in the second part you get those rows where the transportador
's id equals the queried id (TRANS.ID_CLIENTE = @ID_CLIENTE
). Note the TRANS
in the second WHERE
-clause.
For example consider this data:
Cliente
ID_CLIENTE STATUS
----------- --------
1 A
2 X
3 A
Transportador
ID_TRANSPORTADOR ID_CLIENTE
----------------- -----------
1 3
2 2
3 1
When @ID_CLIENTE
= 3 the first select would give you 3 for ID_CLIENTE
, while the second would give 1. Try to understand why!