SELECT b.`name`,a.* FROM `wuliuxianlu` a LEFT JOIN `wuliugongsi` b ON b.`id`=a.`gongsi_id` WHERE `mudede` LIKE '%$mudede%' AND `max_weight`>=$weight and max_weight<=0
union all
SELECT b.`name`,a.* FROM `wuliuxianlu` a LEFT JOIN `wuliugongsi` b ON b.`id`=a.`gongsi_id` WHERE `mudede` LIKE '%$mudede%' and max_weight>0;
union all
SELECT b.`name`,a.* FROM `wuliuxianlu` a LEFT JOIN `wuliugongsi` b ON b.`id`=a.`gongsi_id` WHERE `mudede` LIKE '%$mudede%' and max_weight>0;
WHERE `mudede` LIKE '%$mudede%' AND (max_weight= 0 or `max_weight`>=$weight)