K
K
Kolers2021-02-12 14:35:40
SQL
Kolers, 2021-02-12 14:35:40

SQL check for existence of table values?

Good time sotok, I have two tables, one with dates, the second with IDs and dates, both tables are presented as a selection by the SELECT statement from child tables, and the first one was created using a CTE expression, I need to check for a match between the values ​​of each element from table 2 in the presence of such a value in the elements of table 1, and in case of a match, increase the date values ​​\u200b\u200b(add a day) in this query and display it (do not change anything in tables with inserts) and additions can be recursive, since after adding a day, you will need to check for availability, tell me how it is most convenient to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2021-02-12
@rPman

most sql databases allow you to use the result of the select operation as a table in from (or define such tables).
about adding a day, the LEFT JOIN operator allows you to join tables in from in such a way that the records of the left table will be required as a result, when as records from the right only if the condition matches ON (similarly, there is a RIGHT JOIN, only the count will be for the right table),
respectively, you check the necessary field on null you do plus one
about recursive additions did not understand

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question