473,244 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

Finding duplicate values in 2 different tables

35 32bit
Hello,

I am a very new beginner. I have the following problem I would like to solve. I have a column named matterno in a table named page0. I have another column named court in a table named page2. I would like to find all matterno that have the court duplicated in page2. I would like to include both matterno and court in the results. Can someone assist?

Thanks!
Jan 14 '21 #1
1 7253
Banfa
9,065 Expert Mod 8TB
I'm not a SQL expert but I think the way to do this is to effectively join the table to itself. You have not really given enough detail about you table structures to be able to properly answer this, in particular you have missed out the data about the primary and foreign key fields defined in your tables.

So to answer you I am going to assume that
  1. Both your tables had a id column that is their primary key
  2. Your page2 table has a page0Id column that is the foreign linking page2 to page0
If these assumptions are wrong you will have to correct for them.

Expand|Select|Wrap|Line Numbers
  1. SELECT po.id, p0.matterno, p2a.id, p2a.court, p2a.id, p2b.court 
  2.   FROM page0 AS p0 
  3.   INNER JOIN page2 AS p2a ON p0.id = p2a.page0Id
  4.   INNER JOIN page2 AS p2b ON p2a.court = p2b.court AND p2a.id != p2b.id;
  5.  
I suspect that this will output each duplicate twice but it rather depends on what you are using this for as to the amount of effort you need to go into to fix that.
Jan 19 '21 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: NiQ | last post by:
Hello every one, this is about an array of string and may be have done several time before but i need it and wasnt able to find it so here is the problem i have an array of strings with contains...
20
by: Dennis Gearon | last post by:
I am working on a design where a location for something can have: Fully qualified address with even building names, room numbers, and booth numbers. **-OR-** GPS location **-OR-** Both ...
4
by: satish | last post by:
Values of two columns in two different tables--presentation using select Hi Everyone, i have two tables in the database . One is called address table and one is adressPhone Table. Below...
2
by: fabiola1 | last post by:
I'm using Ms Access 2003. I have five tables called tblAllContract tblType tbInteranlContact tblSupplier tblManager The other four tables are linked to tblAllContracts with Id's.I have a...
4
by: ramdil | last post by:
Hi All I have table and it have around 90000 records.Its primary key is autonumber field and it has also have date column and name, then some other columns Now i have problem with the table,as my...
0
by: sparks | last post by:
I was using this to swap out a form with subforms on it by just making a copy and tying each to copy of the same table. subformV1 tblVisit1 subformV2 tblVisit2 etc Select Case TabCtl0.Value...
2
by: dawn123 | last post by:
I have a 2-d array that the user enters tress species and diameter so it looks something like: sm 10 rm 18 bf 12 sm10 sm10 rm18 and so on.. I need to be able to seach though my array and find...
12
by: stretchtack | last post by:
Hey Troops, I'm not sure if this is allowed, but I'm trying to keep my SP generic and reduce duplicate code. Depending on a condition, I need to JOIN to different tables, which slightly changes...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.