select a.* from
book a,author b,address c
where a.id=b.parentid and b.id=c.parentid
and ( city='北京' or authorname='张三')
book a,author b,address c
where a.id=b.parentid and b.id=c.parentid
and ( city='北京' or authorname='张三')
使用子查询,
这样做效率是不高
left join author b on a.id=b.parentid
left join address c on b.id=c.parentid
where ( c.city='北京' or b.authorname='张三')
或:
select * from book where exists (select 1 from address where (city='北京' or authorname='张三') and rootid=book.rootid)