Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Select items used before a date but not after
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01635849
Message ID:
01635903
Vues:
50
>>>
>>>select * from dbo.part_file p where not exists (select 1 from dbo.part_used pu where used_date >='20100101' and pu.part_pk = p.part_pk)
>>>and exists (select 1 from dbo.part_used pu where used_date <'20100101' and pu.part_pk = p.part_pk)
>>
>>Do I understand correctly that you use aliases (e.g. 'p' and 'pu') for readability but the expression can be used without them, correct?
>
>You can write
>
>part_pk = part_file.part_pk
>
>and not use aliases. But you do need to connect the main query with the exists / not exists subquery. I think using aliases is the simplest way to relate the main query and subquery.

The reason I cannot use aliases is that my VFP code uses SFQuery (as a filter) and SFQuery returns the expression using the actual table names. So if I use the alias, the entire SQL Select does not work (error message). By removing the alias, everything works.
Thank you.
"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