我有2个表TableA
和TableB
,其属性为id, character
TableA
╔════╦═══════════╗
║ id ║ character ║
╠════╬═══════════╣
║ 1 ║ A ║
║ 2 ║ B ║
║ 3 ║ C ║
╚════╩═══════════╝
TableB
╔════╦═══════════╗
║ id ║ character ║
╠════╬═══════════╣
║ 1 ║ A ║
║ 2 ║ B ║
║ 3 ║ D ║
╚════╩═══════════╝
我想计算TableA
和TableB
之间字符列中有多少字符不匹配。
我不确定这是否正确:
SELECT COUNT(character)
FROM TableA tba
JOIN TableB tbb
ON tba.id = tbb.id
WHERE tba.character NOT LIKE tbb.character
GROUP BY character
答案 0 :(得分:0)
您不需要group by语句:
SELECT COUNT(*)
FROM TableA tba
INNER JOIN TableB tbb
ON tba.id = tbb.id
WHERE tba.character <> tbb.character