select A.log_date, A.log_filtime, A.id, B.counts from log_info as A
inner join (select match_id, count(*) as counts from opinion
group by match_id) as op
on A.id = op.match_id
where A.username = 'zhuxx'
order by A.id desc
inner join (select match_id, count(*) as counts from opinion
group by match_id) as op
on A.id = op.match_id
where A.username = 'zhuxx'
order by A.id desc
inner join (select match_id, count(*) as counts from opinion group by match_id) as op on log_info.id = op.match_id
where username = 'zhuxx' order by log_info.id desc
这样可以查出一条纪录,但是不能把所有log_info表中的纪录都查出来,因为当opinion表中没有关于log_info表中的纪录时,是查不出来。难道真的只有去用数组,把log_info表中的纪录先存入数组,然后再根据具体的id来查opinion表中相匹配的记录数?
inner join (select match_id, count(*) as counts from opinion
group by match_id) as op
on A.id = op.match_id
where A.username = 'zhuxx'
order by A.id desc
可以查出一条纪录,但是不能把所有log_info表中的纪录都查出来。不是我上面打的那样。
left join (select match_id, count(*) as counts from opinion
group by match_id) as op
on A.id = op.match_id
where A.username = 'zhuxx'
order by A.id desc