If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Other PC Databases > How to reduce duplicated Field

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-02-08, 09:53
mohinder_kks mohinder_kks is offline
Registered User
 
Join Date: Jan 2008
Posts: 1
How to reduce duplicated Field

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
Reply With Quote
  #2 (permalink)  
Old 01-02-08, 10:12
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,538
Quote:
Originally Posted by mohinder_kks
How to avoid duplicate FieldName (Empid_a,Empid_b)
that's easy -- stop using the dreaded, evil "select star"

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 08-15-08, 19:29
jrbbldr jrbbldr is offline
Registered User
 
Join Date: Nov 2002
Posts: 49
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On