I have two tables in a database. Table1 stores the users and Table2 stores data generated by the users.
Due to an error some users from Table1, don’t have any data in Table2. I would like to notify these users.
I am trying this in several ways using MySQL. But nothing works, because PHPmyAdmin freezes or PHP times out. That’s maybe because the first table contains 28.000 rows and the second one contains 80.000 rows. I just need the last 5 days.
Trial nr 1
SELECT gebruikers.g_id
FROM gebruikers LEFT JOIN objecten ON objecten.o_g_id=gebruikers.g_id
WHERE objecten.o_g_id IS NULL
EXPLAIN SELECT
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE gebruikers index NULL PRIMARY 4 NULL 25227 Using index
1 SIMPLE objecten ALL NULL NULL NULL NULL 81002 Using where; Not ex
Trial nr 2
SELECT g_id FROM gebruikers
WHERE g_id NOT IN(SELECT o_g_id FROM objecten WHERE o_startdatum <= NOW() AND o_startdatum >=NOW() - INTERVAL 5 DAY)
What am i doing wrong?
Query to get required records: