I want to CREATE VIEW of two tables, merge them, where column from table1 != column from table2 and later insert the rows that do not have duplicate columns.
CREATE TABLE IF NOT EXISTS test(Birds, Animals, Air, Earth);
INSERT INTO test VALUES("Crow", "Dog", "Oxygen", "Not Flat");
CREATE TABLE IF NOT EXISTS test1 (Birds, Animals, Air, Earth, Sky);
INSERT INTO test1 VALUES("Crow", "Dog", "Oxygen", "Not Flat", "Blue");
INSERT INTO test1 VALUES("Eagle", "Dog", "Oxygen", "Not Flat", "Blue");
CREATE VIEW view_name AS SELECT * FROM test, test1 WHERE test.Birds != test1.Birds'
test Table:
Birds|Animals|Air|Earth
Crow|Dog|Oxygen|Not Flat
test1 Table:
Birds|Animals|Air|Earth|Sky
Crow|Dog|Oxygen|Not Flat|Blue
Eagle|Dog|Oxygen|Not Flat|Blue
Current output:
Birds|Animals|Air|Earth|Birds:1|Animals:1|Air:1|Earth:1|Sky
Crow|Dog|Oxygen|Not Flat|Eagle|Dog|Oxygen|Not Flat|Blue
Desired output:
Birds|Animals|Air|Earth|Sky
Eagle|Dog|Oxygen|Not Flat|Blue
SELECT Birds, Animals, Air, Earth FROM test1 EXCEPT SELECT Birds, Animals, Air, Earth FROM test
? Not clear exactly which columns you want matched - CharliefaceSky
column which is not present intest
. So trySELECT Birds, Animals, Air, Earth, Sky FROM test1 WHERE EXISTS (SELECT test1.Birds, test1.Animals, test1.Air, test1.Earth EXCEPT SELECT test.Birds, test.Animals, test.Air, test.Earth FROM test)
- Charlieface