Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Select Group By Problem
Message
 
To
15/10/1998 11:52:50
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00147169
Message ID:
00147327
Views:
23
Melissa,
The SQL as written here will give you a Cartesian Join because you have shown no link between table a and table b.

Also, you need to put parentheses around the second Select statement (after the Union:
SELECT a.item, a.loctid FROM a_ictran a, a_icitem b ;
      WHERE RIGHT(a.trantyp,1) = "R" ;
      .AND. BETWEEN(a.item, lc_bitem, lc_eitem) ;
UNION <b>(</b>SELECT a.item, a.loctid FROM a_icytrn a, a_icitem b ;
      WHERE RIGHT(a.trantyp,1) = "R" ;
      .AND. BETWEEN(a.loctid, lc_bloca, lc_eloca)<b>)</b> ;
      INTO CURSOR temp1 ;
      GROUP BY 1 ;
      ORDER BY 1
I would think that VFP has tightened up some of the SQL structure. I know that a thread this week pointed to the necessity for putting fields on the left, variables on the right to Rushmore optimize SQL code.

HTH
Barbara

>The following sql select statement has been working fine in Foxpro version 2.6 for Windows and compiles w/o error. When we compile the program containing the sql select statement in Visual Foxpro ver. 5.0 (upgrading a client's system), we get a syntax error. Further investigation indicates that it is having a problem w/the "group by" clause. Does anyone know why there is now a syntax error in VFP 5.0? Any ideas how to fix it? Thanks in advance for the help.
>
>SELECT a.item, a.loctid FROM a_ictran a, a_icitem b ;
> WHERE RIGHT(a.trantyp,1) = "R" ;
> .AND. BETWEEN(a.item, lc_bitem, lc_eitem) ;
>UNION ;
> SELECT a.item, a.loctid FROM a_icytrn a, a_icitem b ;
> WHERE RIGHT(a.trantyp,1) = "R" ;
> .AND. BETWEEN(a.loctid, lc_bloca, lc_eloca) ;
> INTO CURSOR temp1 ;
> GROUP BY 1 ;
> ORDER BY 1
Barbara Paltiel, Paltiel Inc.
Previous
Reply
Map
View

Click here to load this message in the networking platform