Complex sql query (for me anyway)

Hi Wapplers,

maybe not a wappler query (except I can’t work out how to do this query in wappler). Was hoping there was a wappler guru and sql guru who could point me in the right direction (pretty please)

The scenario. I have created a message table and a message_read table. The messages relate to jobs in the system, so you can go into a job and leave messages. An admin can reply to those messages. When the user logs back in and goes to the messages page they see their messages and it flags if its read or not by left join messages to messages_read. It all works nicely for a normal user.

Now, if an admin logs in, they need to be able to see all messages for all jobs and if THEY have read it.

But, what happens now is when I view messages as an admin I get all messages for all jobs, but, it shows the message as read even if not read by me (only shows read if another user has read it).

Its because of the left join on messages_read - as that pulls in basically that someone has read it but not necessarily me. I kind of need an extra element to that left join on an identity but thats not possible.

I want (as admin) to view the page and show all messages as unread unless I have actually read them.

Sure that is about all as clear as mud, not sure if its possible in Wappler.

Thanks
Darren

Community Page
Last updated: