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 > Database Server Software > MySQL > Display required records from same table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-15-09, 09:40
hemantkumarniec hemantkumarniec is offline
Registered User
 
Join Date: May 2009
Location: Delhi
Posts: 1
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
Reply With Quote
  #2 (permalink)  
Old 05-23-09, 00:38
galih galih is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 05-23-09, 01:09
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
SELECT DISTINCT
       one.local
  FROM daTable AS one
INNER
  JOIN daTable AS two
    ON two.foreign = one.local
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
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