Connecting Tech Pros Worldwide Forums | Help | Site Map

Query from First Table, relation in second Table

Newbie
 
Join Date: Nov 2008
Posts: 1
#1: Nov 18 '08
Hi Friends,

I have two tables, second table has relation

Table1:
----------
Id
----------
A01
A02
A03
A04
A05

Table2
-----------
sid pid
----------
A01 A01
A02 A01


If I use Query table1.id = 'A01', I need to have A01 and A02.
If I use Query table1.id = 'A02', I need to have A01 and A02.
but If I use Query table1.id = 'A03' , need to have only A03

It means A01 and A02 are duplicates. I want to extract duplicates.

Can you help me to get SQL query?

Thanks,
Ashok



Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,648
#2: Nov 18 '08

re: Query from First Table, relation in second Table


I've heard there's some kind of duplicate keyword in sql. anyway, you should ask a moderator to move your thread to the sql forum, since your problem seems to be more of sql than php.

regards
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,747
#3: Nov 18 '08

re: Query from First Table, relation in second Table


Hi.

I have moved this thread over to the MySQL forum.
Please try to post your questions in the appropriate forums.
(See How To Ask A Question)

If you are in fact not using MySQL, but rather some other SQL server, let me know and I will relocate the thread to the proper forum.

Thank you,
Moderator
Reply