Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shifis
Posting Yak Master
157 Posts |
Posted - 2009-09-10 : 22:26:09
|
HiI have a clause that uses an IN condition combine with another condition.What of these options is better:Case 1:SELECT *FROM OP_SOLICITUDES aWHERE exists (SELECT IdProm FROM PROMS where a.SOS_ID_PROMOTORIA =PROMS.IdProm) AND a.SOS_FEC_CREACION BETWEEN (getdate()-30) AND GETDATE() )Case 2:SELECT * FROM OP_SOLICITUDES aWHERE a.SOS_ID_PROMOTORIA IN(SELECT IdProm FROM PROMS ) AND a.SOS_FEC_CREACION BETWEEN (getdate()-30) AND GETDATE() |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
shifis
Posting Yak Master
157 Posts |
Posted - 2009-09-11 : 14:39:46
|
Hi,Thanks for the help.I still confuse about using EXISTS or IN, I read somo articles about this topic, in some of them they said that is better EXISTS and in others that check the execution plan.The confusion is because in all the articles they only mention one condition in the WHERE and here I will use more than one condition, maybe in this case is better use one of both. |
|
|
|
|
|