Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need help with SELECT
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00174354
Message ID:
00174357
Views:
23
>What's wrong with my SELECT statement below?
>
>Error I get - "Command contains unrecognized phrase/keyword."
>
>I am trying to select records for a certain year that have a certain ID code and count/list them by month for assorted zip codes.
>
>cField = cRetVal
>
>SELECT mytable.zip, mytable.date ;
> FROM mytable ;
> WHERE YEAR(mytable.date) = YEAR(DATE())-1 .AND. ;
> WHERE mytable.&cField = "1A" .OR. ;
> mytable.&cField = "1B" .OR. ;
> mytable.&cField = "1C" .OR. ;
> ORDER BY MONTH(mytable.date) ;
> INTO CURSOR rpt
>
>Thanks for helping me out.

In addition to what's Marty says, you don't need ".OR." before ORDER BY
And this one will be shorter:

SELECT mytable.zip, mytable.date ;
FROM mytable ;
WHERE YEAR(mytable.date) = YEAR(DATE())-1 ;
AND mytable.&cField IN ("1A", "1B", "1C") ;
ORDER BY MONTH(mytable.date) ;
INTO CURSOR rpt

Nick
Nick Neklioudov
Universal Thread Consultant
3 times Microsoft MVP - Visual FoxPro

"I have not failed. I've just found 10,000 ways that don't work." - Thomas Edison
Previous
Reply
Map
View

Click here to load this message in the networking platform