SELECT d.`id`, d.`part`, d.`show`, d.`name`, d.`descr`, d.`price`, d.`datetimeadd`, d.`datetimechange`, d.`forumuserid`, d.`forumusername`,
				d.`username`, d.`userphone1`, d.`userphone2`, d.`usericq`, d.`tags`, d.`photo`, d.`countcomment`, d.`lastcomment`, d.`countview`, d.`sold`,
				p.`name` "part_name", rub.`name` "rubric_name", op.`name` "operation_name", t.`dateend` "top", t.`status`, IF(t.`status` = 60, t.`id`, 0) "topid"
				
				FROM `do` d
				INNER JOIN `part` p ON d.`part` = p.`id`
				INNER JOIN `rubric` rub ON d.`rubric` = rub.`id`
				INNER JOIN `operation` op ON d.`operation` = op.`id`
				LEFT JOIN `top` t ON d.`id` = t.`do`
				WHERE d.`show` = 1 AND d.`sold` = 0 
				ORDER BY `topid` DESC,  d.`id` DESC  limit 20 

---------------------
162.158.78.25 15.08.2020 05:11:16  http://komok.bvf.ru/