Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELECT based on a matching record in another table
Message
 
 
À
12/07/2002 12:58:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00678126
Message ID:
00678157
Vues:
14
This message has been marked as a message which has helped to the initial question of the thread.
select cName from Table1 inner join TableB on upper(alltrim(Table1.cName))=upper(alltrim(Table2.cName)) where Table2.LogField = .t.
BTW, strange choice - why do you want alltrim in index? It's not a good idea...

>I'm stumped! I've been looking at this too long I think. I am trying to create a temporary cursor of only those records in table (a) that have a record in table (b) AND whose table (b) field fontreq value =.t.
>
>Here is the structure/relationship:
>
>lcontrol table (a)
>cn_name c(10) *--tag is name and is on UPPER(ALLTRIm(cn_name))
>
>ctrlset table (b)
>ctrlname c(10) *--tag is ctrlname and is on UPPER(ALLTRIM(ctrlname))
>fontreq L *--always .t. or .f. tag is fontreq
>
>lcontrol.cn_name has the same value as its related record in ctrlset.ctrlname
>
>Again, I want to create a temporary cursor that contains the field cn_name from the lcontrol table but it should only contain records that have a matching record in ctrlset *AND* whose fontreq field is .T.
>
>Here is what I've tried:
>
>Example 1:
>
>SELECT cn_name FROM lcontrol x WHERE ;
>   EXISTS (SELECT * FROM ctrlset y WHERE x.cn_name = y.ctrlname)
>
>
>The result from example 1 is that I get ALL records from the lcontrol table for some reason
>
>Example 2:
>
>SELECT cn_name FROM lcontrol x WHERE ;
>   EXISTS (SELECT * FROM ctrlset y WHERE UPPER(ALLTRIM(x.cn_name)) = UPPER(ALLTRIM(y.ctrlname)))
>
>The result from example 2 is that I get an error message "ERROR CORRELATING FIELDS"
>
>If I were to do this using filters, it works correctly doing this:
>
>
>SELE lcontrol
>SET ORDER TO TAG NAME    && tag is ALLTRIM(UPPER(cn_name))
>SELE ctrlset
>SET ORDER TO TAG CTRLNAME    && tag is ALLTRIM(UPPER(ctrlname))
>SET FILTER TO ctrlset.fontreq=.T.
>SELE lcontrol
>SET RELATION TO cn_name INTO ctrlset
>SET FILTER TO FOUND('ctrlset')
>
>
>This shows the correct records, but I need a select statement so I can have a temporary cursor to use and also not disrupt the dataenvironment (relationships) already in place.
>
>I've tried a BUNCH of other SQL statements, but I think I've just looked at this too much and its all blurry!!!!
>
>Any ideas?
>THANKS in advance,
>Tracy
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform