Tag Info

New answers tagged

0

Looking at the linked code you don't understand: select count(*) from ( select * From EmpDtl1 union select * From EmpDtl2 ) The secret sauce is using union as opposed to union all. The former retains only distinct rows whereas the latter keeps duplicates (reference). In other words the nested querys says "give me all rows and columns from EmpDtl1 and in ...


0

In create table you have set teams as primary key, and also you are aware that primary key does not allow duplicate values. mysql> create table tblShowteam( -> SetId int, -> datum date, -> teams int, -> primary key (teams)); Query OK, 0 rows affected (0.13 sec) Check the ...


6

One option is to use a FULL OUTER JOIN between the two tables in the following form: SELECT count (1) FROM table_a a FULL OUTER JOIN table_b b USING (<list of columns to compare>) WHERE a.id IS NULL OR b.id IS NULL ; For example: CREATE TABLE a (id int, val text); INSERT INTO a VALUES (1, 'foo'), (2, 'bar'); CREATE ...


7

You can use the EXCEPT operator. For example, if the tables have identical structure, the following will return all rows that are in one table but not the other (so 0 rows if the tables have identical data): (TABLE a EXCEPT TABLE b) UNION ALL (TABLE b EXCEPT TABLE a) ; Or with EXISTS to return just a boolean value or a string with one of the 2 possible ...



Top 50 recent answers are included