Hi Joe

Single letter aliases are bad especially in VFP. The best thing is not
even to use CurA, CurB, but to use aliases that have meaning. Saving a
few keystrokes of typing really does not help in the long run. Cut and
paste is your friend. Any saving in time typing is far outweighed by
having to puzzle through unreadable SQL.

I find it far better, (easier to read, easier to understand!!!, easy
enough to type), to use (as an example) Inv. and Lin. as aliases for
Invoice and LineItems. There is no reason to study the options.
Obvious beats obscure every time.

Mike Yearwood
Microsoft MVP Visual FoxPro - 2008

> Message: 6
> Date: Mon, 09 Feb 2009 10:57:09 -0500
> From: Joe Yoder <[email protected]>
> Subject: RE: SQL help
> To: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset="us-ascii"
>
> Thanks Dave,
>
> Yet another approach added to my VFP Q & A folder for a day when I can
> afford to study all options.  I know about the pitfalls of single letter
> aliases and wondered whether I would get bitten in this code.  I tried it
> this way to keep it as small as possible and to see if I could get away
> with it.  VFP let me but you didn't!  Seriously I appreciate all your
> help.  Thank you! - Joe
>
> On Monday, February 09, 2009 10:21 AM, Dave Crozier wrote:
> >
> >Date: Mon, 9 Feb 2009 15:21:44 -0000
> >From: Dave Crozier
> >To: [email protected]
> >cc:
> >Subject: RE: SQL help
> >
> >* Define and load demo cursors
> >CREATE CURSOR curA (Id I)
> >CREATE CURSOR curB (Parent I, Type C(1))
> >
> >INSERT INTO curA (Id) VALUES (1)
> >INSERT INTO curA (Id) VALUES (2)
> >
> >INSERT INTO curB (Parent, Type) VALUES (1, 'a')
> >INSERT INTO curB (Parent, Type) VALUES (1, 'b')
> >INSERT INTO curB (Parent, Type) VALUES (2, 'a')
> >
> >SELECT curA.id, ;
> >  curB.type as typ1, ;
> >  curB2.type as typ2;
> >FROM curB ;
> >RIGHT JOIN curA ON curA.id == curB.parent AND curB.type = 'a' ;
> >LEFT JOIN curB as curB2 ON curA.id == curB2.parent AND curB2.type = 'b'
> >
> >Note that the logic is transferred from your Where condition into the join
> >condition. This is where it needs to be in order to get the correct data.
> >
> >Also, its bad form to use single letter aliases and this method or naming
> >can get you into all sorts of trouble, hence the slight renaming of cursors
> >in my example
> >
> >Dave Crozier

_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to