select distinct a.code,a.name
from table1 a,table2 b
where a.code=b.code and 日期>=date1 and 日期<=date2
或select distinct a.code,a.name
from table1 a,table2 b
where a.code=b.code and 日期 between date1 and date2
from table1 a,table2 b
where a.code=b.code and 日期>=date1 and 日期<=date2
或select distinct a.code,a.name
from table1 a,table2 b
where a.code=b.code and 日期 between date1 and date2
right join table2 b
on a.code=b.code
where b.日期 between date1 and date2
from table1 a join table2 b
on a.code=b.code and 日期>=date1 and 日期<=date2
或select a.name
from table1 a join table2 b
on a.code=b.code and 日期 between date1 and date2
from table1 a,table2 b
where a.code=b.code and b.日期 between date1 and date2
left join table2 t2 on t1.code = t2.code
where convert(varchar(10), 日期, 120) >= convert(varchar(10), date1, 120)
and convert(varchar(10), 日期, 120) <= convert(varchar(10), date2, 120)我想date1和date2应该是日期(不包含时间的),如果包含时间,就不用convert了