Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL UNION with Memo fields
Message
From
23/10/1997 12:53:10
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00056360
Message ID:
00056385
Views:
26
>>>This has to be done in FoxPro 2.5 so views are not an option.
>>>
>>>I have 2 separate tables both with a date field and a memo field. Both date fields are called Readdate. The memo field in table1 is called Comments and table2's is called Cparam.
>>>
>>>What I need to end up with is a Cursor, combining both tables data, with Readdate, Comments, Cparam ordered by Readdate. How do I code the SQL-SELECT for this or is there a better way? My best idea so far is 2 SELECT's UNION'd together.
>>
>>
>>SELECT ReadDate, Myfield1 AS Field1, MyField2 AS Field2, Comments ;
>> FROM MyTable1 ;
>>UNION ;
>>SELECT ReadDate, MyOtherField1 AS Field1, MyOtherField2 AS Field2, Cparam AS Comments ;
>> FROM MyTable2 ;
>>ORDER BY 1 ;
>>INTO CURSOR ac_Cursor
>>
>>
>>The 'AS' commmands are redundant, I just put them in for clarification.
>>
>>The Format for Myfield1 MUST match MyOtherField1 and likewise for 2.
>>
>>HTH
>
>I don't think that's quite what I'm after. Table1's structure is Readdate (Date) and Comments (Memo). Table2's structure is Readdate (Date) and Cparam (Memo). What I want to end up with is a cursor with a structure of Readdate (Date), Comments (Memo) and Cparam (Memo). I believe my SQL should be something like this:
>
>SELECT ReadDate, Comments, MyField1 ;
> FROM MyTable1 ;
>UNION ;
>SELECT ReadDate, MyField2, Cparam ;
> FROM MyTable2 ;
>ORDER BY 1 ;
>INTO CURSOR ac_Cursor
>
>MyField1 has to be the same type and size as Cparam and the same is true for MyField2 and Comments for the UNION to work. Since both Comments and Cparam are Memo fields, how do I define the dummy values of MyField1 and MyField2?

Create Cursor dummy (mymemo m)
select dummy
append blank

SELECT ReadDate, Comments, mymemo ;
FROM MyTable1, dummy ;
UNION ;
SELECT ReadDate, mymemo, Cparam ;
FROM MyTable2, dummy ;
ORDER BY 1 ;
INTO CURSOR ac_Cursor

Should get you what you're looking for.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform