INTERSECT in MySQL

You can use an inner join to filter for rows that have a matching row in another table: SELECT DISTINCT records.id FROM records INNER JOIN data d1 on d1.id = records.firstname AND data.value = “john” INNER JOIN data d2 on d2.id = records.lastname AND data.value = “smith” One of many other alternatives is an in … Read more

The opposite of Intersect()

As stated, if you want to get 4 as the result, you can do like this: var nonintersect = array2.Except(array1); If you want the real non-intersection (also both 1 and 4), then this should do the trick: var nonintersect = array1.Except(array2).Union( array2.Except(array1)); This will not be the most performant solution, but for small lists it … Read more

Alternative to Intersect in MySQL

Microsoft SQL Server’s INTERSECT “returns any distinct values that are returned by both the query on the left and right sides of the INTERSECT operand” This is different from a standard INNER JOIN or WHERE EXISTS query. SQL Server CREATE TABLE table_a ( id INT PRIMARY KEY, value VARCHAR(255) ); CREATE TABLE table_b ( id … Read more

tech