I wrote a query that check if a team
is updated. The condition to check the update is: if the field update_at
of the team
is greather than 7 days from the current date, then the record need to be updated, eg:
id | name | update_at
67 Tirana 2019-03-06 11:00:12
68 Partizan 2019-03-06 11:02:04
69 Lusitanos 2019-03-14 09:00:40
SELECT id
FROM team
WHERE update_at < DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)
AND id IN (67, 68, 69);
the query works well, infact the result above is: 67, 68, becasue the record 69
is already updated (doesn't fit the condition).
Now suppose that the record that I'm looking for doesn't exist in the database, the query will not return it (and this is good), but how can I check if the record need to be added instead of update? eg:
id | name | update_at
67 Tirana 2019-03-06 11:00:12
68 Partizan 2019-03-06 11:02:04
69 Lusitanos 2019-03-14 09:00:40
SELECT id
FROM team
WHERE update_at < DATE_SUB(CURRENT_DATE, INTERVAL 7 DAY)
AND id IN (67, 68, 69, 70);
the result is even 67, 68. But contrary to the first example, here the record 70
doesn't exist, so how can I know that using one query?
Is possible return two result such as record_to_update
and record_to_add
?