select sendconf.id
from sendconf
where exists(select jobid from edmsrc
where sendconf.jobid=edmsrc.jobid and edmsrc.sendtime<='2007-03-01')select sendconf.id
--max(sendconf.id)
from sendconf inner join edmsrc on sendconf.jobid=edmsrc.jobid
where edmsrc.sendtime<='2007-03-01'
from sendconf
where exists(select jobid from edmsrc
where sendconf.jobid=edmsrc.jobid and edmsrc.sendtime<='2007-03-01')select sendconf.id
--max(sendconf.id)
from sendconf inner join edmsrc on sendconf.jobid=edmsrc.jobid
where edmsrc.sendtime<='2007-03-01'
from sendconf
where exists(select jobid from edmsrc
where sendconf.jobid=edmsrc.jobid and edmsrc.sendtime<='2007-03-01')
这个是取表sendconf的jobid存在于表edmsrc中且edmsrc.sendtime<='2007-03-01'的结果。select sendconf.id
from sendconf inner join edmsrc on sendconf.jobid=edmsrc.jobid
where edmsrc.sendtime<='2007-03-01'
这个是先取两表中jobid相等的数据,然后再从这些数据中筛选出edmsrc表中的sendtime
的字段<'2007-03-01'的数据。
select sendconf.id
from sendconf
where exists(select jobid from edmsrc
where sendconf.jobid=edmsrc.jobid and edmsrc.sendtime<='2007-03-01')
--生成笛卡尔积
select sendconf.id
--max(sendconf.id)
from sendconf inner join edmsrc on sendconf.jobid=edmsrc.jobid
where edmsrc.sendtime<='2007-03-01'从查询结果上来看应该是数据的行数不一样,如果都加上DISTINCT 则结果集会相同