mysql left join查询

SELECT * FROM `_bidding_tb` as `db` , `_member` AS dm LEFT JOIN `_member_emcee` AS de ON dm.mid = de.mid LEFT JOIN `_member_person` AS dp ON dm.mid = dp.mid WHERE dm.mtype<>'企业' AND `db`.`mid` = `dm`.`mid` AND `db`.`aid` = 221
SELECT fb.*,mb.userid,mb.face as mface,mb.spacesta,mb.scores FROM `_feedback` fb left join `_member` mb on mb.mid = fb.mid where fb.aid='$aid' and fb.ischeck='1' order by fb.id desc limit 0, 50

SELECT v.*,m.uname,m.sex,face FROM `_member_vhistory` AS v  LEFT JOIN `_member` AS m ON v.vid=m.mid WHERE 条件 ORDER BY vtime DESC

由此可看出LEFT JOIN的强大之处,从左表向右表开始查询,在经过第二个表的时候用ON v.vid=m.mid来进行关联

Leave a Reply

(will not be published)