Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copy data in table one to table two and update a field
Message
From
19/04/2006 16:11:57
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
19/04/2006 10:58:23
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01114387
Message ID:
01114745
Views:
25
>Thanks for responding.
>
>Here is a restatement of my question. I hope this is clearer.
>
>On a server there exist 2 tables where table 1 is what I call the a header table. It has data about who ordered items form a vendor and the primary key is a requition number. Table 2 is what I call the detail table and it contains infromation about the order with where the primary key is also the requition number and the secondary key is a line number. The relationship is 1 to n. The second table has a field which indicates where the order goes (a site code). I need to add this site code to table 1. What I want to do is copy table 1 and 2 from the server to my PC. I want to this while the system is being used by users at seveal sites.
>
>Then I want to copy the data in table 1 to another table which will have the additonal field (site code). Since table 2 has site code in it I want to extract the site code from table 2 for each requition number and then use it to update the new table with the extracted site code data. A simplied exmple
>
>Table 1
>
>req rest of data
> no
> 1  ...
> 2  ...
> 3  ...
>  etc
>
>New table 1 after coping data from table 1 (note site code is blank)
>
>req site  rest of data
> no cide
> 1         ...
> 2         ...
> 3         ...
>   etc
>
>Table 2
>
>req  line  site  rest of data
> no   no   code
> 1    1    a     ...
> 1    2    a     ...
> 2    1    a     ...
> 3    1    b     ...
> 3    2    b     ...
> 3    3    b     ...
>    etc
>
>Extracted data
>
>req  site
> no  code
> 1   a
> 2   a
> 3   b
>      etc
>
>New table 1 with site codes
>
>req  site  rest of data
> no  code
> 1   a     ...
> 2   a     ...
> 3   b     ...
>   etc
>
>What I asking for is the best way to do this. I tried using set path and it did not appear to work for the last park. Do I need several programs?
select distinct t1.*, t2.sitecode from ;
  table1 t1 ;
  left join table2 t2 on t1.reqno == t2.reqno ;
  into table newTable1
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