有 a、b、c三张表,结构相同,都有以下字段:id name date btime etime想得到这中查询结果:
a.id,a.name,a.date,a.btime,a.etime,b.btime,b.etime,c.btime,c.etime按id和date来关联我这样写查的好慢,大家看看怎么优化或者有没有其他更好的方法啊:
select a.id,a.name,a.date,a.btime,a.etime,b.btime,b.etime,c.btime,c.etime
from a,b,c
where a.id=b.id and a.date=b.date and a.id=c.id and a.date=c.date order by a.name
a.id,a.name,a.date,a.btime,a.etime,b.btime,b.etime,c.btime,c.etime按id和date来关联我这样写查的好慢,大家看看怎么优化或者有没有其他更好的方法啊:
select a.id,a.name,a.date,a.btime,a.etime,b.btime,b.etime,c.btime,c.etime
from a,b,c
where a.id=b.id and a.date=b.date and a.id=c.id and a.date=c.date order by a.name
from a inner join b on a.id=b.id and a.date=b.date
inner join c on a.id=c.id and a.date=c.date
--date id建索引
像这样:
id name date time1 time2 time3 time4 time5 time6