Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subquery syntax
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2014
Application:
Web
Miscellaneous
Thread ID:
01615658
Message ID:
01615670
Views:
25
>>>If you're looking into a query from table1 where you don't have rows with today's day and field2 = 'ABC' in the second table, then use NOT EXISTS subquery, e.g.
>>>
>>>select * from Table1 T1 where not exists (select 1 from Table2 T2 where T2.id_field = T1.id_field
>>> and CAST(T2.date_fld  as date) = cast(CURRENT_TIMESTAMP as date)
>>>and T2.field2 = 'ABC')
>>
>>Without testing, intuitively I think that this one would be faster. Thank you.
>
>If you only need rows from Table1 which satisfy the condition of not having corresponding rows in table2 with today's date and particular value of the field2, then this is the query you should use. It is fast and the other one has different meaning.

How do I modify your SQL Select so that if the value in T2.date_fld is equal to the current date, do not include in the resulting query?
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform