dbTalk Databases Forums  

VFP 6: Query Problem

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss VFP 6: Query Problem in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gene Wirchenko
 
Posts: n/a

Default VFP 6: Query Problem - 11-15-2004 , 10:16 PM






The following query has been giving me grief. The error I get is
"SQL: Error correlating fields". The docs are less than clear on what
this means.

select *;
from cwko as gsm;
where;
gsm.wccode="GSM" and not exists;
(;
select .f.;
from cwko as notgsm;
where;
notgsm.clcode=gsm.clcode and;
left(dtos(notgsm.trndtlow),6)=left(dtos(gsm.trndtl ow),6) and;
left(dtos(notgsm.trndthi),6)=left(dtos(gsm.trndthi ),6) and;
notgsm.wccode#"GSM";
);
order by
gsm.clcode,gsm.trndtlow,gsm.trndthi,gsm.wccode,gsm .wonbr

I am looking for all work orders with a wccode of "GSM" where
there is no work order for that month for that client with a wccode of
other than "GSM".

The VFP 9 beta throws the same error.

I tried other things including calculated columns, but any way
that I have gone about it, the subquery throws an error of some sort.

What am I missing?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Reply With Quote
  #2  
Old   
Martin Gebert
 
Posts: n/a

Default Re: VFP 6: Query Problem - 11-16-2004 , 04:19 AM






Gene Wirchenko schrieb:
Quote:
select *;
from cwko as gsm;
where;
gsm.wccode="GSM" and not exists;
This "not exists" looks odd to me; is this a valid SQL construct? Can
you try it with something like

....and gsm.ID not in (select gsm.ID...

or maybe a

{Query 1}
minus
{Query 2}

(too lazy to check if VFP supports "minus")?

Martin

Quote:
(;
select .f.;
from cwko as notgsm;
where;
notgsm.clcode=gsm.clcode and;
left(dtos(notgsm.trndtlow),6)=left(dtos(gsm.trndtl ow),6) and;
left(dtos(notgsm.trndthi),6)=left(dtos(gsm.trndthi ),6) and;
notgsm.wccode#"GSM";
);
order by
gsm.clcode,gsm.trndtlow,gsm.trndthi,gsm.wccode,gsm .wonbr


Reply With Quote
  #3  
Old   
Martin Gebert
 
Posts: n/a

Default Re: VFP 6: Query Problem - 11-16-2004 , 04:25 AM



Martin Gebert schrieb:

Quote:
Gene Wirchenko schrieb:

select *;
from cwko as gsm;
where;
gsm.wccode="GSM" and not exists;


This "not exists" looks odd to me; is this a valid SQL construct?
Oops, sorry, I should have said "'not exists' in combination with
'select .f.' looks odd". Try selecting a column in your subquery.

Quote:
Can
you try it with something like

...and gsm.ID not in (select gsm.ID...
And this, of course, should read "...(select notgsm.ID..." :-(

Excuse me, it's still too early in the day...

Martin


Quote:
or maybe a

{Query 1}
minus
{Query 2}

(too lazy to check if VFP supports "minus")?

Martin

Reply With Quote
  #4  
Old   
Bill Browne
 
Posts: n/a

Default Re: VFP 6: Query Problem - 11-17-2004 , 11:32 PM



Gene and Anders:
I've been following this as best I can, and I might be looking at this
wrong, but here's what I see:

It seems that you both have been discussing what occurs in the 'where'
clause in the subquery. But I see the result of Gene's subquery as being
the problem. It looks to me that the subquery would return a single column
of .f. with a field name of I-can't-imagine-what, which fox would not be
able to line up with the main query. But Ander's last post, where the
subquery starts with 'select *' would give valid fields that fox could align
with the main query.

Run _just_ the subquery below, and I think you will see what I mean.

Standard disclaimers....
--
Bill Browne
www.edgefinderstudios.com


"Gene Wirchenko" <genew (AT) mail (DOT) ocis.net> wrote

Quote:
The following query has been giving me grief. The error I get is
"SQL: Error correlating fields". The docs are less than clear on what
this means.

select *;
from cwko as gsm;
where;
gsm.wccode="GSM" and not exists;
(;
select .f.;
from cwko as notgsm;
where;
notgsm.clcode=gsm.clcode and;
left(dtos(notgsm.trndtlow),6)=left(dtos(gsm.trndtl ow),6) and;
left(dtos(notgsm.trndthi),6)=left(dtos(gsm.trndthi ),6) and;
notgsm.wccode#"GSM";
);
order by
gsm.clcode,gsm.trndtlow,gsm.trndthi,gsm.wccode,gsm .wonbr

I am looking for all work orders with a wccode of "GSM" where
there is no work order for that month for that client with a wccode of
other than "GSM".

The VFP 9 beta throws the same error.

I tried other things including calculated columns, but any way
that I have gone about it, the subquery throws an error of some sort.

What am I missing?

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.



Reply With Quote
  #5  
Old   
Gene Wirchenko
 
Posts: n/a

Default Re: VFP 6: Query Problem - 11-18-2004 , 11:11 AM



"Bill Browne" <bill (AT) excalibur-dbf (DOT) com> wrote:

Quote:
Gene and Anders:
I've been following this as best I can, and I might be looking at this
wrong, but here's what I see:

It seems that you both have been discussing what occurs in the 'where'
clause in the subquery. But I see the result of Gene's subquery as being
the problem. It looks to me that the subquery would return a single column
of .f. with a field name of I-can't-imagine-what, which fox would not be
able to line up with the main query. But Ander's last post, where the
It does not have to "line up" the two queries. I am using the
exists operator with the subquery. That operator returns true or
false. What is returned by the subquery is irrelevant, except for the
question whether there is anything at all. I use select .f. because
it will create a smaller result.

Quote:
subquery starts with 'select *' would give valid fields that fox could align
with the main query.

Run _just_ the subquery below, and I think you will see what I mean.

Standard disclaimers....
Where? What? The above is the last line of your post.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.