View Full Version : How to reduce duplicated Field
mohinder_kks
01-02-08, 10:53
| Hi,
I have using visual foxpro 6.0.Here i try to select data from two table at time
recive duplicated Field .
For example,
Table1;
Empid empname dpartment
1 mur cs
2 kks ms
3 kkk Us
Table2;
Empid FirstName LastName
1 kskd k
2 kkks u
Query:
select * from Table1,Table2 where Table1.Empid=Table2.Empid
Output Is
Empid_a empname dpartment Empid_b FirstName LastName
1 mur cs 1 kskd k
2 kks ms 2 kkks u
Here,
How to avoid duplicate FieldName (Empid_a,Empid_b)
I need only Empid empname dpartment FirstName LastName after execute above query
Please replay me |
How to avoid duplicate FieldName (Empid_a,Empid_b)that's easy -- stop using the dreaded, evil "select star"
:)
| The reason that the SQL Query results in VFP produce
Empid_a & Empid_b is that the field exists twice - once in table1 and once in table2. VFP will not allow 2 fields with the same name to co-exist so it is re-naming the fields to be different.
The way to get around this is to input the fields specifically instead of using the '*' (star) operator.
SELECT Field1, ;
Field2, ;
Field3, ;
Table1.Empid as Empid1, ;
Field4, ;
Table2.Empid as Empid2;
<and so on...>
Good Luck |
vBulletin v3.5.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.