Click here to Skip to main content
16,022,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 tables [Test1 - Test2]

Test1 Columns:-
Test1Informations
Test1Data
Test1Company
TestID Foreign Key
Test1Code
Test1Image

Test2 Columns:-
TestID Primary Key
Test2Image
Test2Data
TestName

i want to retrieve the TestName Value using foreign key
Posted

<pre>SELECT Test1.* , Test2.TestName FROM Test1 INNER JOIN Test2 ON Test1.TestID Foreign Key = Test2.TestID Primary Key WHERE ....</pre>

After WHERE you can put whatever condition you want to search by, this is what I could do and I hope I helped

Good Luck :-)
 
Share this answer
 
v2
Comments
Member 11144083 31-Oct-20 14:18pm    
2020 and still working like a charm
Are you wondering about joins? You can join the two tables using the foreign key for example like:
SELECT *
FROM Test1 INNER JOIN Test2
     ON Test1.TestID = Test2.TestID

That would bring all the matching rows. For information about joins, see: http://www.w3schools.com/sql/sql_join.asp[^]
 
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