Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2008
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    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"

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Nov 2002
    Posts
    128
    Provided Answers: 1
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •