+----------------------------+ +----------------------------+
| ID | Date | | ID | Date |
+----------------------------+ +----------------------------+
| 1 | 2017-06-13 22:10:01 | | 1 | 2017-06-20 22:10:50 |
+----------------------------+ +----------------------------+
| 2 | 2017-06-14 13:22:20 | | 2 | 2017-06-23 22:10:55 |
+----------------------------+ +----------------------------+
| 3 | 2017-06-16 22:10:01 | | 3 | 2017-06-27 22:10:35 |
+----------------------------+ +----------------------------+
| 4 | 2017-07-04 22:10:07 |
+----------------------------+
I have 2 tables, same columns. The first one will be a sample, having entries on a week basis, each with 1-minute difference (10 080 entries in total). While the other one gets new values everytime (1 min), indefinitely.
What I try to do is compare each new entry with an entry from the first database. But I want to compare depending on weekday and time (same hour and same minutes).
For instance, an entry on Monday at 11:00 (whatever month, day and year) should be compared with one on Monday at 11:00 from the sample database.
What I want to do is get the number of the entry from sample database when it's the same weekday as the entry in the second table:
2017-06-20 22:10:50 should return 1.
2017-06-23 22:10:55 should return 3.
2017-06-27 22:10:35 should return 1.
2017-07-04 22:10:07 should return 1.
Edit2:
I think you may understand things better when I explain the purpose of the two tables.
The real tables in my database have more columns: sensors' id and their value.
The first table, sample table, will have data received for a whole week. It's used as a reference.
The second table receives data every minute, when one gets in it should be compared with a record in the sample table to detect if values are equals or not(anormal value).
So I want to detect abnormal values by comparing with a record of same weekday, same hours and minutes.