Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Subquery syntax
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2014
Application:
Web
Divers
Thread ID:
01615658
Message ID:
01615680
Vues:
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))
I think your first SQL selelct was correct. I didn't update the id_Field correctly. You have been very helpful.
Thank you very much!
"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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform