我正在尝试根据相对外键关系中的 2 个以上条件过滤主表行,我想出了这个工作正常,但我无法说服自己这是一个大惊小怪
select r.pageid
from
((
select co.pageid
from (cmscontentpublished as co join cmsnode as cm on co.PageID = cm.ID)
where cm.parentid=365 and co.Title='Title' and co.Content like '%test%'
)
union all
(
select co.pageid
from (cmscontentpublished as co join cmsnode as cm on co.PageID = cm.ID)
where cm.parentid=365 and year(co.DateContent) =2012
)) as r
group by r.pageid
having COUNT(*)=2
关于如何正确做的任何想法
试试这是否适合你