By displaying the records insert them at the same time

0

I have a 3 tables in my database

fecha_busqueda         fecha_encontrar               fecha_resultado
-------------         ---------------                ----------------
id_fechab int         id_fechae  int                  id_fechar    int
fechab    datetime    fechae     datatime             fechar       datetime

This is the issue

The search_date table has full date records and the date_find table has date records that are not in the date_search date.

Perform an inner join to compare which dates are not in the date_find Then I'm given a list of dates.

What I want to do is that this list of dates that I did not find to insert them in the date_result along with the date_find, I can understand?

that result that I throw myself to do an insert of all the date_find and insert the results that I did not find in the date_search

and so I get a date_result with the date_finding record and the one that I did not find.

Ex.

search_date I have 10 records and the date_find I have 7 means that there are no 3 dates to find a compared to the other table then he throws me the dates that he did not find

and I want to show all 7 dates of date_find and insert them on date_result along with those I did not find and so I have 10 dates equal to the other.

    
asked by Jose carlos 27.04.2018 в 05:31
source

1 answer

0

I think I understood what you mean ...

EDIT: I did not understand you, I modified the answer

You do not need an INNER JOIN, with inserting all the results of both tables would be enough.

For that you would need to do a INSERT with a SELECT in:

INSERT INTO fecha_resultado
        (id_fechar, fechar)
SELECT id_fechab, fechab
FROM   fecha_busqueda
WHERE  id_fechab IS NOT NULL
 UNION
SELECT id_fechae, fechae
FROM   fecha_encontrar
WHERE  id_fechab IS NOT NULL 
    
answered by 27.04.2018 / 12:32
source