Joining Tables | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Joining Tables

SELECT t1.Field1
FROM Table1 t1
JOIN Table2 t2 ON t2.Field1 = t1.Field2
WHERE t1.Field1 NOT IN
(SELECT Field1 FROM Table3 WHERE ID = 1) it’s too slow if I have too many records in Table3. If I could do this in some other way, maybe (or most probably a join) then it would help in the problem in my other post. Thanks.
?? what was the trouble? Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
http://www.sql-server-performance.com/tuning_joins.asp
http://www.sql-server-performance.com/developers_tuning_tutorial.asp Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
Did you try something like this? SELECT t1.Field1
FROM Table1 t1
JOIN Table2 t2 ON t2.Field1 = t1.Field2
LEFT JOIN Table3 t3 ON t3.Field1 = t1.Field2 AND t3.ID <> 1
hi chopeen! I haven’t tried it, it worked anyway. Is there a big difference then, regarding performance?
hi again! chopeen, i tried the query you gave me and it gave me different result with the one i have. thanks.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by blueFrench</i><br /><br />I haven’t tried it, it worked anyway. Is there a big difference then, regarding performance?<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br />It’s hard to tell. [<img src=’/community/emoticons/emotion-2.gif’ alt=’:D‘ />] Since I do not know what difference we are talking about.<br /><br /><i>My query and yours from your first post in this topic?</i><br />It’s you who said it is too slow.<br /><br /><i>My query and your new one?</i><br />I haven’t seen the new one.<br /><br />–<br /><br />
hi chopeen! what i mean is that when you try my code (the one posted here) and the one you suggested, it will give us diff. result. thanks.
quote:Originally posted by blueFrench

what i mean is that when you try my code (the one posted here) and the one you suggested, it will give us diff. result.

I was afraid of this. I created some sample data to test my and your query. Both gave me the same results, so I hoped it’s gonna work fine.
]]>