Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2016
    Posts
    1

    Unanswered: SQL Query Question

    hello All,
    I have something like this :

    Table 1

    CustID Name

    116 John

    Table2

    LangID CustID LangName

    001 116 English

    002 116 French

    Table3

    AvailID CustID Date

    101 116 Jan 08 2016

    What I'm trying to accomplish is to return all columns in Table 1 where LangName from Table 2 = 'English'

    simple approach:

    select * from Table1, Table2, Table3 where Table2.LangName = 'English'

    The problem is I end up with:

    116 English Jan 08 2016

    116 French Jan 08 2016

    I just need the first row from table 1
    Any help is appreciated.

    Thanks again

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Use a join to expressly relate the tables to each other. Then use the where clause appropriately to limit the rows returned
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    or be more explicit in your joins and use the ON clause to JOIN them.
    Dave

  4. #4
    Alright, Just give a try with the following SQL format and let me know if it works.

    Select table1.custid, table1.name from Table1
    JOIN table2 ON ( table1.custid = table2.custid )
    JOIN table3 ON (( table2.custid = table3.custid) AND ( table2.langname ="english"))

Posting Permissions

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