If I have two tables, such as:
CREATE TABLE
INSERT INTO
INSERT INTO
INSERT INTO
INSERT INTO
CREATE TABLE
INSERT INTO
INSERT INTO
INSERT INTO
And I want to see all the rows that appear in only one of the tables, what would be the best way to do this?
All I can think of is to do:
SELECT * from
UNION
SELECT * from
Or something like strings:
SELECT id,MAX(name) as name FROM
(
SELECT *,1 as count from
SELECT *,1 as count from
) data
group by id
HAVING SUM(count) =1
To bring back Alan, Fred and Steve in this case.
But they seem awkward - is there a better way to get closer to this?
source
share