473,915 Members | 3,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Finding duplicate values in 2 different tables

35 New Member
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 7600
Banfa
9,065 Recognized Expert Moderator Expert
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
3027
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 words and i want a distinct list of array with the count of each number repeat i.e how many time it exist in the array and the final result should be sorted according to the number of repeat from hight to low . for example
20
2143
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 Other than triggers, is there a way to enforce this using tables and
4
2458
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 is the sample of those two tables
2
1879
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 bound form called frmViewContracts where i view all my contracts on the system.This form is from query called qryViewContracts.
4
2925
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 table contains duplicate entries for a particular date.How can i delete the duplicate entries from the table for that particular column,Now i am doing manually with name column as it will be unique for that date.Can any one help me giving the query...
0
1393
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 Case 0: 'Initial Visit Child6.SourceObject = "subformV1"
2
3632
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 all the duplicate values and know the number of each dupliate value so sm 10 would be 3 and rm 18 would be 2 and so on.. until the end of the array. I then will take that array and seach for a value in another array.. ( i think i may be able to do...
12
51750
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 the result set. So, I would include conditions later to grab the proper fields based on checking the same condition (@TravelType = 'A'). Here's a sample of what I'm doing, which is currently giving me a syntax error near 'CASE': CASE WHEN...
0
9883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
11069
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.