问愚蠢的问题......得到愚蠢的答案。根据对问题的解释,这可能正确也可能不正确。
/*records from table A are in table B with same phone number and project_name; */
SELECT count(*), A.Phone, A.Project_name
FROM A
INNER JOIN B
on A.Phone = B.Phone
and A.project_name = B.Project_name
GROUP BY A.Phone, A.Project_name
/*same phone number and different project_name*/
SELECT count(*), A.Phone, A.Project_name
FROM A
INNER JOIN B
on A.Phone = B.Phone
and A.project_name <> B.Project_name
GROUP BY A.Phone, A.Project_name
/*different phone and same project_name*/
SELECT count(*), A.Phone, A.Project_name
FROM A
INNER JOIN B
on A.Phone <> B.Phone
and A.project_name = B.Project_name
GROUP BY A.Phone, A.Project_name
/*different phone and different project_name*/
SELECT count(*), A.Phone, A.Project_name
FROM A
INNER JOIN B
on A.Phone <> B.Phone
and A.project_name <> B.Project_name
GROUP BY A.Phone, A.Project_name