Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankajkumar PatelRank #181 · 13.4K reputationPosted Nov 10, 2022, 12:42 AM EST
Hi Naresh Beniwal,
INTERSECT can be used in MS SQL to retrieve common records from two tables as like following:
SELECT Subject_code FROM students INTERSECT SELECT Subject_code FROM teacher;For more details:
Hope, this will help you!
Uday DodiyaRank #239 · 10.3K reputationPosted Nov 10, 2022, 2:20 AM EST
Hi Naresh,
Use Intersect Key word, which gives you common records.
SELECT column1 FROM table1 INTERSECT SELECT column1 FROM table2If you want in the output both column1 and column2 from table1 which has common columns1 in both tables.
SELECT column1, column2 FROM table1 WHERE column1 IN ( SELECT column1 FROM table1 INTERSECT SELECT column1 FROM table2 )Rajanikant HawaldarRank #110 · 20.2K reputationPosted Nov 10, 2022, 12:54 AM EST
(Select * from student) Intersect (Select * from student1)https://www.c-sharpcorner.com/blogs/fetch-only-common-records-from-two-tables
Jignesh KumarRank #91 · 22.9K reputationPosted Nov 10, 2022, 5:45 AM EST
Hi Naresh,
You can use Intersect or Inner Join to get common records from two tables.
Onkar SharmaRank #104 · 20.6K reputationPosted Dec 8, 2022, 2:07 PM EST
Hi,
To learn about how to find common records from two tables, visit:
Thanks!