Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Looking for more optimization
Message
 
 
To
11/02/2009 22:34:18
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Application:
Web
Miscellaneous
Thread ID:
01381114
Message ID:
01381128
Views:
47
>>I don't see why you need JOIN in this case. Wouldn't following query produce the same result?
>>
>>SELECT Member.Numero,Member.Nom,Member.Prenom,Member.LastAccess
>>	FROM Member 
>>	WHERE Member.LastAccess >= @LastAccess 
>>		AND Member.Numero = @NoMember
>>		AND EXISTS ( SELECT 1 FROM Monitor WHERE Monitor.NoMember2 = @NoMember )
>>	ORDER BY 2	
>>
>
>I think you wanted to write this:
>
>
>DECLARE @NoMember Integer
>DECLARE @LastAccess DateTime
>
>SET @NoMember=1
>SET @LastAccess='2009-02-10 11:46:55'
>
>SELECT Member.Numero,Member.Nom,Member.Prenom,Member.LastAccess
> FROM Member 
> WHERE Member.LastAccess>=@LastAccess 
> AND EXISTS (SELECT 1 FROM Monitor WHERE Monitor.NoMember2=Member.Numero AND Monitor.NoMember=@NoMember)
>
>
>Is that correct?
>
>If yes, is this an optimized route?

Can you tell a bit more about the structure of your tables and what exactly you're trying to achieve with this query?

Also can you do a simple join with Monitor table instead?

E.g.
SELECT Member.Numero,Member.Nom,Member.Prenom,Member.LastAccess
 FROM Member INNER JOIN Monitor ON Monitor.NoMember2=Member.Numero 
 WHERE Member.LastAccess>=@LastAccess and Monitor.NoMember=@NoMember
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform