MyBB Community Forums

Full Version: How to filter by threads that have attachments?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Like the subject says, I'm looking to find out how to filter by threads that have attachments. In other words, only show a list of threads that contain attachments and not show those that don't.

Appreciate any help with this.
This is going to be complicated and I'm not 100% sure if this will work.
SELECT a.*, t.* FROM mybb_attachments a
LEFT JOIN mybb_posts p ON(a.pid=p.pid)
LEFT JOIN mybb_threads t ON(p.tid=t.tid)
ORDER BY t.lastpost DESC
LIMIT 10;
(2015-01-12, 08:13 PM)dragonexpert Wrote: [ -> ]This is going to be complicated and I'm not 100% sure if this will work.


SELECT a.*, t.* FROM mybb_attachments a
LEFT JOIN mybb_posts p ON(a.pid=p.pid)
LEFT JOIN mybb_threads t ON(p.tid=t.tid)
ORDER BY t.lastpost DESC
LIMIT 10;

Thank you for the reply. Is this to be used in the AdminCP or on the front end? I'm looking for users browsing the threadlist to be able to do the filtering (i.e. front end).

Also, if that is what I use to do what I'm looking for, what do I do with that code?
That's the SQL query you'd need. A plugin is what would be required if its something you want. I was trying to assist you by providing the query since that is usually the most difficult part. If you want me to move this to Plugin Requests, let me know.
I see. I appreciate the help. There's no easy way to accomplish this without a plugin? I try to limit plugins and mods to keep things running well. I have no problem going thru files/code and making changes if you would be able to assist me in getting this working completely.

If not, moving this to Plugin Requests is appreciated.
It's going to be a combination of PHP and SQL so moved.