Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper syntax when using UNION
Message
From
24/01/2002 12:52:55
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/01/2002 12:49:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00609414
Message ID:
00609885
Views:
20
>>I found a situation I can't explain. I have the following SQL:
>>
>>
>>SELECT NOCLIENT,NOCAT,NUMERO,NOMEMBER,NOPARENT,NOTHREAD,ADDDATE,ADDHEURE,TITLE,.T. AS FLAG,1;
>> FROM THREAD WHERE NoClient=5 AND NUMERO>=600000;
>>UNION SELECT NOCLIENT,NOCAT,NUMERO,NOMEMBER,NOPARENT,NOTHREAD,ADDDATE,ADDHEURE,TITLE,.T. AS FLAG,0;
>> FROM THREAD WHERE NoClient<>5 AND NUMERO>=600000;
>> ORDER BY 11 DESCENDING,1,2,6,5 INTO CURSOR TEMP READWRITE
>>
>>
>>The only way to make that work is to use an ORDER BY clause with numeric references. As soon as I put the UNION clause in it, I am forced to use numeric references for the SQL. Why is that?
>
>Michel,
>Would this be an alternative solution ?
>
SELECT distinct NOCLIENT,NOCAT,NUMERO,NOMEMBER,NOPARENT,;
>  NOTHREAD,ADDDATE,ADDHEURE,TITLE,.T. AS FLAG,iif(NoClient=5,1,0) as myExp ;
> FROM THREAD WHERE NUMERO>=600000 ;
> ORDER BY 11 DESCENDING,1,2,6,5 INTO CURSOR TEMP READWRITE
>
Cetin

BTW forcing to numeric values should be related with you have an expression in order by.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform