Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I want to add new fields that exist in another database 2

Status
Not open for further replies.

RussA

Programmer
Mar 19, 2003
27
US
Is there a simple way in FP60 to combine the fields from two tables? In other words I want to add new fields that exist in another database to my table with out using table designer. Just like appending records but instead appending fields.

Thanks in advance Russ A.
 
RussA,

The simplest way to do it is SELECT-SQL.
If you want just empty table with all those fields, then

SELECT a.*, b.* FROM a, b WHERE .f. INTO DBF MyTable

If you need data from both tables there, you have to use JOIN clause. It's all in the Help.

Stella
 
The thing about Stella's select clause, is that if the two tables are free tables and have any field names that are the same, they will be added to the output table with unique names.
For example, say table1 and table2 both have a field named 'Name'. The result table will have two fields named name_1 and name_2.
If table1 and table2 both have a field named 'data_field' (note that the field name is 10 characters), the result table will contain 'data_fiel1' and 'data_fiel2'

If you know the field names that are different, you can use the ALTER TABLE command to change the table structure:
ALTER TABLE MyTable ADD 'SomeField' c(10)

If you need to compare structures first, create an array using afields() on both tables, loop through and compare, and keep a list of differences.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
You are right, in most cases I don't even think of databases, since I prefer to use free tables, and have to use free table for many reasons.
 
Thanks stella740pl & DSummZZZ that worked well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top