How to show a relation between two persons in a datagridview

Siesta

I want to show a relation between two persons in a datagridview (C# Windowsforms).

So, I made a (MS Access) table with persons. Each person has an unique number as its PK. Thereafter I made a Relation table. In this table I have a column for person 1 (FK), a column for the relation and a column for person 2 (FK).

This looks like this:

ERD

Now I tried to show this in a datagridview with columns that show Fname, Lname, DOB, Relation, Fname, Lname, DOB. I tried a lot, but I can't let it work.

I hope someone can let me know how the (SQL) select query should look like or what I should do to make this work.

Thanks a lot!

Lee Mac

You will need to use two references of your Person table in your query, since, for each record in your Relation table, two separate records are to be displayed from your Person table.

Therefore, you'll need to use a query along the lines of:

select
    p1.fname, 
    p1.lname, 
    p1.dob, 
    r.relation,
    p2.fname, 
    p2.lname, 
    p2.dob
from
    (relation r inner join person p1 on r.pnumber1 = p1.pnumber) 
    inner join 
    person p2 on r.pnumber2 = p2.pnumber

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Detect relation between two persons in text

How to show the logical relation between two Pandas dataframes?

How can I show mutual relation between two users in database?

How to show relation between two boxes containing same data in two different treemaps

One common hobby between two persons in Prolog

How to show relation between interfaces and classes in UML?

How to extract only person A's statements in a conversation between two persons A and B

How to divide a pie between persons in PHP?

Relation between two arrays

how to create a parent child relation between two tables mysql

How to set relation between two objects without fetch them

How to create a relation between two modules using EntityFramework Core?

How to make a relation between two objects in database JAVA

How to represent multiple relation between two entity sets in ERD?

How to merge rows of two tables when there is no relation between the tables in sql

How to retrieve data between two table with no proper relation

How to do a relation between two maps with a Object key

How can I quickly switch between different "Chrome Persons"?

How to show result in datagridview?

Longest relation between two strings

JAVA - relation between two objects

Relation between two join tables

Relation between two Fact tables

relation between two columns Python

Django Relation between two models

relation between two dropdownlist in mvc

How to show dates between two dates

How to show table rows between two days?

C# show data between two dates in Datagridview. Dates from DatetimePicker or Textbox