mysql有两个结果集,MySQL:两个结果集的差异
How can I get the set difference of two result sets?
Say I have a result set (just one column in each):
result1:
'a'
'b'
'c'
result2:
'b'
'c'
I want to minus what is in result1 by result2: result1 - result2 such that it equals:
difference of result1 - result2:
'a'
解決方案
To perform result1 - result2, you can join result1 with result2, and only output items that exist in result1. For example:
SELECT DISTINCT result1.column
FROM result1 LEFT JOIN result2 ON result1.column = result2.column
WHERE result2.column IS NULL
Note that is not a set difference, and won't output items in result2 that don't exist in result1. It's set subtraction.
總結
以上是生活随笔為你收集整理的mysql有两个结果集,MySQL:两个结果集的差异的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: useradd -g mysql mys
- 下一篇: mysql5.7rpm安装 force_