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:
01615677
Views:
33
>Sorry I am not clear. Let me clarify. Table2 could have many records with the field ID_FIELD matching the ID_FIELD in the Table1. I want ONLY those that have entry 'ABC' in field FIELD2 to be considered. That is, if the entry in FIELD2 is '123' do not even consider it. But if the entry in the FIELD2 is 'ABC' (FIELD2 = 'ABC') consider it. But if it was created today (that is, DATE_FLD is equal to the current date - today), exclude it.
select T1.* from Table1 T1 where exists (select 1 from Table2 T2 where T2.IdField = T1.IDField and T2.Field2 = 'ABC')
and not exists (select 1 from Table2 T3 
where T3.IdField = T1.IdField and CAST(T3.dateField as date) = CAST(CURRENT_TIMESTAMP as DATE))
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