R
R
rusel009 -2021-09-24 15:03:22
SQL
rusel009 -, 2021-09-24 15:03:22

How to form a correct query in SQL?

Comrades, tell me, please, I'm self-taught, I was driven by the topic to prescribe a specific request, but I can't figure out how to do it correctly.
Query essence:
I have 4 tables:
Customer 1 contains information Customer 2 contains information
ID1.1 personalfileid datestar1, dateend1 ID2.1 personalfileid datestar1, dateend1
ID1.2 personalfileid datestar2, dateend2 ID2.2 personalfileid datestar3, dateend3
ID1.3 personalfileid datestar3 dateend3 ID2.3 personalfileid datesta1r, dateend1
ID1.4 personalfileid datestar4, dateend4 ID2.4 personalfileid datestar2, dateend2

Customer 3 contains information Customer 4 contains information
ID3.1 personalfileid datestar1, dateend1 ID4.1 personalfileid datestar1, dateend1
ID3.2 personalfileid datestar3 dateend3 ID4.2 personalfileid datestar1, dateend1
ID3.3 personalfileid datestar1 dateend1 ID4.3 personalfileid datesta4r, dateend4
ID3. 4 personalfileid datestar4, dateend4 ID4.4 personalfileid datestar2, dateend2

Here's how I can write a query to display only those IDs from all tables by personalfileid that match the datestar1 dateend1 period (the period can be dynamic).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2021-09-30
@karonion

The period can be specified with a where statement and then beetwen or like, for example
Display all personalfield with JOIN
SELECT *
FROM CUSTOMER1 AS C1 JOIN CUSTOMER2 AS C2
ON C1.PERSONALFIELD = C2.PERSONALFIELD
WHERE datestar1 ='&'
And dateend1 ='&'
Personalfield for this must match in all tables

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question