dbTalk Databases Forums  

VFP6: Query Problem

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


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



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

Default VFP6: Query Problem - 03-22-2005 , 01:04 PM






What is wrong with
select left(workdesc,50) as wd,* from cwkt;
where left(funccode,1)="$" and "P#"$wd order by wd
where workdesc is a memo?

I do not get an error message, but I also get no rows returned.
I expected plenty, and the rows are there. If I replace the second
conjunct with
"P#"$workdesc
it works.

What is the difference in meaning between the two statements?
("P#" will normally be at the beginning of the memo.)

Sincerely,

Gene Wirchenko


Reply With Quote
  #2  
Old   
Alexandre Peshansky
 
Posts: n/a

Default Re: VFP6: Query Problem - 03-22-2005 , 01:41 PM






On Tue, 22 Mar 2005 11:04:02 -0800, Gene Wirchenko
<genew (AT) ucantrade (DOT) com.NOTHERE> wrote:

Quote:
What is wrong with
select left(workdesc,50) as wd,* from cwkt;
where left(funccode,1)="$" and "P#"$wd order by wd
where workdesc is a memo?

I do not get an error message, but I also get no rows returned.
I expected plenty, and the rows are there. If I replace the second
conjunct with
"P#"$workdesc
it works.

What is the difference in meaning between the two statements?
("P#" will normally be at the beginning of the memo.)

Sincerely,

Gene Wirchenko
Gene,
"AS wd" clause of SELECT command has not been processed yet when command
is interpreted, so your WHERE condition referring to wd should always
returns false. I am surprised that it doesn't barf on "ORDER BY wd" -
it should be "ORDER BY 1" to work. Must be version-specific.
--
[ When replying, remove *'s from address ]
Alexandre Peshansky, Systems Manager, RUH, NY


Reply With Quote
  #3  
Old   
Fred Taylor
 
Posts: n/a

Default Re: Query Problem - 03-22-2005 , 02:03 PM



"wd" is not yet known by the WHERE condition parser. It doesn't become
known until the records are retrieved and needed for the ORDER BY. At
least, that's my SWAG on how it works, I have no inside actual knowledge of
the way the VFP SQL parser works.

--
Fred
Microsoft Visual FoxPro MVP


"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote

Quote:
What is wrong with
select left(workdesc,50) as wd,* from cwkt;
where left(funccode,1)="$" and "P#"$wd order by wd
where workdesc is a memo?

I do not get an error message, but I also get no rows returned.
I expected plenty, and the rows are there. If I replace the second
conjunct with
"P#"$workdesc
it works.

What is the difference in meaning between the two statements?
("P#" will normally be at the beginning of the memo.)

Sincerely,

Gene Wirchenko




Reply With Quote
  #4  
Old   
Paul Pedersen
 
Posts: n/a

Default Re: Query Problem - 03-22-2005 , 02:43 PM



I agree.

Also, PADR(workdesc, 50) would be better than LEFT(workdesc, 50), because
you might run into a short workdesc some day, and your resulting field will
then be smaller than you expect.




"Fred Taylor" <ftaylor (AT) mvps (DOT) org!REMOVE> wrote

Quote:
"wd" is not yet known by the WHERE condition parser. It doesn't become
known until the records are retrieved and needed for the ORDER BY. At
least, that's my SWAG on how it works, I have no inside actual knowledge
of the way the VFP SQL parser works.

--
Fred
Microsoft Visual FoxPro MVP


"Gene Wirchenko" <genew (AT) ucantrade (DOT) com.NOTHERE> wrote in message
news:5fq0419s5v6lg87jitouvn0rkba75ckbtt (AT) 4ax (DOT) com...
What is wrong with
select left(workdesc,50) as wd,* from cwkt;
where left(funccode,1)="$" and "P#"$wd order by wd
where workdesc is a memo?

I do not get an error message, but I also get no rows returned.
I expected plenty, and the rows are there. If I replace the second
conjunct with
"P#"$workdesc
it works.

What is the difference in meaning between the two statements?
("P#" will normally be at the beginning of the memo.)

Sincerely,

Gene Wirchenko






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 - 2013, Jelsoft Enterprises Ltd.