如果有天我们湮没在人潮之中,庸碌一生,那是因为我们没有努力要活得丰盛。善于与人沟通,适度采纳别人意见。
Doing INTERSECT and MINUS in MySQL Doing an INTERSECT An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So can simply be rewritten to
SELECT member_id, name FROM a
INTERSECT
SELECT member_id, name FROM b
Performing a MINUS
SELECT a.member_id, a.name
FROM a INNER JOIN b
USING (member_id, name)
To transform the statement
into something that MySQL can process, we can utilize subqueries (available from MySQL 4.1 onward). The easy-to-understand transformation is:
SELECT member_id, name FROM a
MINUS
SELECT member_id, name FROM b
Of course, to any long-time MySQL user, this is immediately obvious as the classical use-left-join-to-find-what-isn't-in-the-other-table:
SELECT DISTINCT member_id, name
FROM a
WHERE (member_id, name) NOT IN
(SELECT member_id, name FROM table2);
SELECT DISTINCT a.member_id, a.name
FROM a LEFT JOIN b USING (member_id, name)
WHERE b.member_id IS NULL
以上就是MySQL不支持INTERSECT和MINUS及其替代方法。除了少许的天份之外,大多是靠努力得来的“三分天才,七分努力。”是成功不变的法则,一个不愿或不肯努力的人,比起原地踏步,还要糟糕,所以要好好把握一分一秒的时刻,作为迈向下一步的准备,如此才能扎实稳固。更多关于MySQL不支持INTERSECT和MINUS及其替代方法请关注haodaima.com其它相关文章!