Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UNION with ORDER BY
Message
From
19/06/2007 13:02:25
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01234316
Message ID:
01234322
Views:
12
>>Hi Gang....
>>
>>This code throws up a "SQL: Order By clause is invalid" error.
>>
>>
>>SELECT * from regtrans ;
>>	WHERE regtrans.trans_date >= Thisform.cntDates.txtFrom.Value AND ;
>>		  regtrans.trans_date <= Thisform.cntDates.txtTo.Value ;
>>	UNION ;
>>SELECT * from tranhist ;
>>	WHERE tranhist.trans_date >= Thisform.cntDates.txtFrom.Value AND ;
>>		  tranhist.trans_date <= Thisform.cntDates.txtTo.Value ;
>>	INTO CURSOR csrTotalTran ORDER BY trans_date, trans_time
>>
>>
>>What is wrong?
>>
>>Thanks!
>
>Union needs order by the field # (order by 5,6), not field name.

That works for me:
CREATE CURSOR crsTest1 (Fld1 I)
CREATE CURSOR crsTest2 (Fld1 I)
FOR asd = 1 TO 20
    INSERT INTO crsTest1 VALUES(asd)
NEXT
FOR asd = 21 TO 50
    INSERT INTO crsTest2 VALUES(asd)
NEXT

SELECT * FROM CrsTest1;
WHERE Fld1%3 = 0;
UNION;
SELECT * FROM CrsTest2;
WHERE Fld1%2 = 0;
INTO CURSOR ccc;
ORDER BY Fld1
BROWSE NORMAL
VFP9 SP1


UPDATE: Didn't work in VFP8.
Tommy, better next time show us the version of VFP you work with :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform