Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper syntax when using UNION
Message
From
25/01/2002 05:55:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/01/2002 15:31:48
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00609414
Message ID:
00610345
Views:
23
Zlatin,
It'd work if you take time to 'as' ordering fields with a 'different' name. But I simply can't understand why I need the union here. If you don't have it then you don't need the 'as' for existing fields too, right? If he'd edit this and use in update, with renaming fields would need more conversion :(
Cetin

>I must admit that I have missed something:
>The correct command will be
>
>SELECT NOCLIENT AS O_NOCLIENT ,NOCAT AS O_NOCAT,NUMERO,NOMEMBER,NOPARENT AS O_NOPARENT,NOTHREAD AS O_NOTHREAD,ADDDATE,ADDHEURE,TITLE,.T. AS FLAG,1 AS ORDERF ;
> FROM THREAD WHERE NoClient=5 AND NUMERO>=600000;
>UNION SELECT NOCLIENT AS O_NOCLIENT ,NOCAT AS O_NOCAT,NUMERO,NOMEMBER,NOPARENT AS O_NOPARENT,NOTHREAD AS O_NOTHREAD,ADDDATE,ADDHEURE,TITLE,.T. AS FLAG,0 AS ORDERF;
> FROM THREAD WHERE NoClient<>5 AND NUMERO>=600000;
> ORDER BY ORDERF DESCENDING,O_NOCLIENT,O_NOCAT,O_NOTHREAD,O_NOPARENT INTO CURSOR TEMP READWRITE
>
>
>So If you wish to use order by with names you should have additional AS clauses with names different from your field names.
>
>I have tested it with only one order by clause and this was why I did not post you the correct query the first time
Ç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
Next
Reply
Map
View

Click here to load this message in the networking platform