Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make real PostRows with SQL
Message
 
 
To
11/02/2003 17:25:17
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00752072
Message ID:
00752357
Views:
8
You can use IIF() function. Something like (not tested, just illustrates an idea).
SELECT 
       IIF( EMPTY(company), PADR(ALLTRIM(firstname+" "+lastname),32),company)  as PostRow1, ;
       IIF( EMPTY(company), street, PADR(ALLTRIM(firstname+" "+lastname),32)) as PostRow2, ;
       IIF( EMPTY(company), city, street) as PostRow3, ;
       IIF( EMPTY(company), SPACE(LEN(city)), city) as PostRow4 ;
FROM   TabSource ;
INTO TABLE TabTarget1
>* Hello to all VFP-SQL Professionals,
>
>* I search an solution to get Post Rows from a Adresstable.
>* For example, I have got this Sourcetable:
>* TabSource.dBF
>*+------------+---------+--------+-------------+------------+
>*|Company     |FirstName|LastName|Street       |City        |
>*|c(20)       |c(10)    |c(10)   |c(20)        |            |
>*+------------+---------+--------+-------------+------------+
>*|            |Mickey   |Mouse   |MainStreet 1 |Disneyland  |
>*|Wondercars  |Batman   |        |Castle 12    |Gotham City |
>*|            |Donald   |Duck    |PoorStreet 13|Ducktown    |
>*+------------+---------+--------+-------------+------------+
>
>* The SQL Command to get a Targettable with PostRows is easy.
>SELECT company                         as PostRow1, ;
>       ALLTRIM(firstname+" "+lastname) as PostRow2, ;
>       street                          as PostRow3, ;
>       city                            as PostRow4 ;
>FROM   TabSource ;
>INTO TABLE TabTarget1
>
>* So I get this TabTarget1.dBF
>*+------------+-------------+-------------+------------+
>*|PostRow1    |PostRow2     |PostRow3     |PostRow4    |
>*+------------+-------------+-------------+------------+
>*|            |Mickey Mouse |MainStreet 1 |Disneyland  |
>*|Wondercars  |Batman       |Castle 12    |Gotham City |
>*|            |Donald Duck  |PoorStreet 13|Ducktown    |
>*+------------+-------------+-------------+------------+
>* But this is not really a Table with PostRows.
>*
>* How knows the SQL solution, to get this Targettable
>* with this real PostRows.
>*+------------+-------------+-------------+------------+
>*|PostRow1    |PostRow2     |PostRow3     |PostRow4    |
>*+------------+-------------+-------------+------------+
>*|Mickey Mouse|MainStreet 1 |Disneyland   |            |
>*|Wondercars  |Batman       |Castle 12    |Gotham City |
>*|Donald Duck |PoorStreet 13|Ducktown     |            |
>*+------------+-------------+-------------+------------+
>
>* Many thanks for help.
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform