Click here to Skip to main content
15,905,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible that a column in one table primary key and the other column in another table with same datatype primary key? It is also mention that I will join two table
Posted
Comments
vijay__p 7-May-13 5:53am    
Can you please elaborate your question more in detail?
Sumon562 7-May-13 6:06am    
I want to join two table with a common field and same datatype and both the field is primary key. I want to join the two table with the above mentioned field
Sumon562 7-May-13 6:22am    
Hi patel_vijay . I have explained the question

Yes why not. That is the concept of Foreign Key[^].

The other column will be primary key in the other table and will be referenced in the first table as Foreign key.

Refer - SQL FOREIGN KEY Constraint[^].

So, depending on that column you can join.
SQL
SELECT columnName
FROM 
Table1
INNER JOIN
Table2
ON Table1.Column1 = Table2.Column1
-- (Add some condition if you want using WHERE)
 
Share this answer
 
Comments
Sumon562 7-May-13 6:24am    
Thank you. But I do not declare theTable2.Column1 column as foreign key. both columns are primary key.
Ok, Then do like this. It will fetch data. Have you tested ?
yes, It is possible if you have any problem please write your query.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900