I'm trying to figure out how best to write a statement that omits returning rows (maintable
) that a user (uuid_user
) has already seen (seentable
).
- Q: Should I have the "seen" table be a separate table for each user?
Currently, I have it as a single seen
table for all users
Rows that a user has already seen are stored in seentable
for each uuid_user
. Here is a simplified version of my tables. uuid
is used as the key to join. uuid_user
identifies the particular user's seen rows.
Not quite working:
SELECT *
FROM maintable m
LEFT JOIN seentable s
on m.uuid = s.uuid
WHERE s.uuid IS NULL and s.uuid_user = '[user]'
maintable
uuid (char36)
lng,lat (POINT)
timestamp (timestamp)
seentable
uuid (char36)
uuid_user (char36)
timestamp (timestamp)