Consulting

Results 1 to 3 of 3

Thread: SQL query with 2 differenet table

  1. #1
    VBAX Mentor
    Joined
    Feb 2012
    Posts
    406
    Location

    SQL query with 2 differenet table

    Hello , I have Table with this column


    • Table1 has columns (ID, Name, TEXTTYPE , LANGID) and sample data:
      (1, John, RB, 11),
      (2, Peter, PM, 12),
      (3, Mary, RB, 11)
      (4, Kristina, RB, 11)
    • Table2 has columns (TEXTTYPE , LANGID , Description, TRANSLATE) and sample data:
      (RB , 11, Apple, FR),
      (PM, 12, Apricot, GB),
      (RB , 14, Aubergine, TR),
      (PM, 12, Orange, FR),
      (RB, 11, Banana, GB)


    I need The below result only Show FR value in TRANSLATE column:

    (1, John, RB, 11 , Apple),
    (2, Peter, PM, 12, Orange),
    (3, Mary, RB, 11, Apple),
    (4, Kristina, RB, 11, Apple)

    I need this query for Oracle.
    Last edited by parscon; 07-09-2015 at 12:05 AM.

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    As long as there is duplicate information in the tables your query will always return information that you may not want.

    (RB , 11, Apple, FR), <--- Same as last line
    (PM, 12, Apricot, GB), <---- Same as 4th line
    (RB , 14, Aubergine, TR),
    (PM, 12, Orange, FR), <--- Same as second line
    (RB, 11, Banana, GB) <---- Same as first line

    Select table1.ID, table1.Name, table1.texttype table1.langid inner join table2.langid, table2.description

    The above query may have the inner join incorrect but it is a start, I do not have Oracle to test it with.

  3. #3
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Need to do a subselect. Assuming the fields TEXTTYPE, LANGID are distinct -

Posting Permissions

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