MyBB Community Forums

Full Version: Please help me to fix this query?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have a problem with this one. It fetches user last threads but the problem is when I move user thread is shows second duplicated thread that has no views neither replies:

$query = $db->query("
		SELECT t.*, t.subject AS threadsubject, u.username, u.displaygroup, p.displaystyle AS threadprefix,
		t.dateline AS threaddate, t.lastpost AS threadlastpost
		FROM ".TABLE_PREFIX."threads t
		LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
		LEFT JOIN ".TABLE_PREFIX."users u ON (t.lastposter=u.username)
		WHERE t.visible = '1' And t.uid = '{$memprofile['uid']}'
		GROUP BY t.tid
		ORDER BY threadlastpost DESC
		LIMIT 0, {$threadlimit}
	");
Change:
WHERE t.visible = '1' And t.uid = '{$memprofile['uid']}'
to:
WHERE t.visible = '1' AND t.uid = '{$memprofile['uid']}' AND t.closed NOT LIKE 'moved|%'
Wow is there something you don't know LOL. Thanks very much.