Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
2 tables to get one
Message
From
08/09/2006 18:51:11
 
 
To
08/09/2006 16:54:49
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01152459
Message ID:
01152485
Views:
22
>>Hi all,
>>
>>I have 2 tables ( table1 and table2) to become 1 single tableFinal but the structure is incremented .
>>
>>table1.dbf ( 2 fields )
>>
>>empno grade1
>>11111 10
>>22222 20
>>33333 30
>>
>>table2.dbf ( 2 fields )
>>
>>empno grade2
>>11111 11
>>22222 22
>>33333 33
>>
>>How to create SQL statment in order to have tableFinal like this ?
>>
>>TableFinal ( now 3 fields ) always order by empno.
>>
>>empno grade1 grade2
>>11111 10 11
>>22222 20 22
>>33333 30 33
>>
>>Thank you in advance for helping me out.
>
>You can use this:
>
>SELECT table1.empno, grade1, grade2 FROM table1,table2 WHERE table1.empno = table2.empno ORDER BY table1.empno
>
Just in case you run into a situation where you don't have a record for a particular empno in both tables.......
table1.dbf (2 fields)
empno  grade1
11111  10
22222  20
33333  30
44444  40

table2.dbf ( 2 fields )

empno  grade2
11111  11
22222  22
33333  33
55555  55
you can modify the query to be something like
SELECT NVL(table1.empno,table2.empno),table1.grade1,table2.grade2 FROM table1;
 FULL JOIN table2 ON table1.empno=table2.empno
 ORDER BY 1
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform