Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Location
    Delhi
    Posts
    1

    Unanswered: Display required records from same table

    Hi all,

    I get stuck in a query . My table as:


    local foreign
    1 1
    2 1
    5 7
    4 6
    3 2
    1 6
    6 8
    3 8

    I want to find those "local" records which are in "foreign" column [(1 or 2) and (7) and (6)].

    Please help me to solve this query.

    Thanks in advance.

    Hemant Kumar Upadhyay
    FiveE Technology , New Delhi

  2. #2
    Join Date
    Feb 2008
    Location
    Bandung - Indonesia
    Posts
    15
    SELECT local FROM table_name
    WHERE local=foreign

    Unique?

    SELECT DISTINCT local FROM table_name
    WHERE local=foreign
    Forum Informatika - Indonesian Informatics Online Community - http://if.web.id

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT DISTINCT
           one.local
      FROM daTable AS one
    INNER
      JOIN daTable AS two
        ON two.foreign = one.local
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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