两表多条件关联查询问题
有两张表,表a,表b
表a:
id unitid photonumber1 photonumber2
===============================================
1 1111
2 12345678
3 22
4 1111
5 12345678
6 11
7
8 12345678
表b:
photonumber unitid
============================
12345678 11
98765441 22
11109101 33
想得到条件unitid包含11的所有表a记录,并包括表a字段unitid为空,但与表b通过photonumber关联,unitid也为11的记录.
查询结果表:
id unitid photonumber1 photonumber2
================================================
1 1111
2 12345678
4 1111
5 12345678
6 11
8 12345678