The SQL intersect operator returns rows that are common between two tables without returning duplicate records.
Questions tagged [intersect]
643 questions
15
votes
6 answers
SQL: Syntax error with intersect?
This is my query:
-- Sids of suppliers who supply a green part AND a red part
(SELECT Suppliers.sid
FROM Suppliers
JOIN Catalog ON Catalog.sid = Suppliers.sid
JOIN Parts ON Parts.pid = Catalog.pid
WHERE Parts.color = "red")
INTERSECT
(SELECT…

Nick Heiner
- 119,074
- 188
- 476
- 699
14
votes
2 answers
Intersect with a custom IEqualityComparer using Linq
Long story short: I have 2 collections of objects. One contains good values (Let's call it "Good"), the other default values (Mr. "Default"). I want the Intersect of the Union between Good and Default, and Default. In other words:…

Tipx
- 7,367
- 4
- 37
- 59
12
votes
3 answers
Intersect all possible combinations of list elements
I have a list of vectors:
> l <- list(A=c("one", "two", "three", "four"), B=c("one", "two"), C=c("two", "four", "five", "six"), D=c("six", "seven"))
> l
$A
[1] "one" "two" "three" "four"
$B
[1] "one" "two"
$C
[1] "two" "four" "five"…

enricoferrero
- 2,249
- 1
- 23
- 28
10
votes
1 answer
Groovy: Difference with a.intersect( b ) and b.intersect( a )
Why in Groovy, when I create 2 lists, is there a difference if I do a.intersect( b ) and b.intersect( a ):
def list1 = ["hello", "world", "world"];
def list2 = ["world", "world", "world"];
println( "Intersect list1 with list2: " + list1.intersect(…

divillysausages
- 7,883
- 3
- 25
- 39
10
votes
4 answers
Function to find symmetric difference (opposite of intersection) in R?
The Problem
I have two string vectors of different lengths. Each vector has a different set of strings. I want to find the strings that are in one vector but not in both; that is, the symmetric difference.
Analysis
I looked at the function setdiff,…

Gyan Veda
- 6,309
- 11
- 41
- 66
8
votes
1 answer
Does INTERSECT have a higher precedence compared to UNION?
If we consider three single-column tables each having two rows: A = (1, 2), B = (2, 3), C = (3, 4). Then if we try UNION and INTERSECT together using parenthesis, the result is quite consistent:
(select * from a union select * from b) intersect…

The Impaler
- 45,731
- 9
- 39
- 76
8
votes
2 answers
UIBezierPath intersect
I've been searching for an answer for hours but have trouble finding anything on the topic.
I have a question related to Objective-c. I'm making an application in which a UIView checks for touches from the user and if the user touches and moves…

JesperWingardh
- 148
- 1
- 6
7
votes
2 answers
POSTGIS TopologyException: side location conflict
I'm trying to execute a simple st_intersects query:
select st_intersects('MULTIPOLYGON(((1 5,4 8,7 5,4 2,1 5)),((5 5,8 8,11 5,8 2,5 5)))','POLYGON((3 4.5,3 5,4 5,4 4,3 4.5))');
which crush the console and returns the following error:
Error:…

Eden Katabi
- 271
- 1
- 2
- 9
7
votes
5 answers
DELETE WITH INTERSECT
I have two tables with the same number of columns with no primary keys (I know, this is not my fault). Now I need to delete all rows from table A that exists in table B (they are equal, each one with 30 columns).
The most immediate way I thought is…

Nizam
- 4,569
- 3
- 43
- 60
7
votes
3 answers
Intersect in SQL Server
Is there a way to use intersect without selecting distinct values only? Something like INTERSECT ALL.
For example, consider table A and B
A --> 1, 1, 1, 2, 3, 4
B --> 1, 1, 2
Would result in
Result --> 1, 1, 2
EDIT
I think this link explains well…

Nizam
- 4,569
- 3
- 43
- 60
7
votes
3 answers
How to get the union/intersect/difference from two arrays of hashes and ignore some keys
I want to get the union/intersect/difference from two arrays of hashes for example:
array1 = [{:name =>'Guy1', :age => 45},{:name =>'Guy2', :age => 45}]
array2 = [{:name =>'Guy1', :age => 45},{:name =>'Guy3', :age => 45}]
...
p array1 - array2…

Seth Pollack
- 269
- 2
- 13
7
votes
4 answers
Overlapping Ranges Check for Overlapping
I have a list of ranges and I would like to find out if they overlap.
I have the following code. Which does not seem to be working. Is there an easier way to do this or a way that works :)
Thanks in advance for any advice.
public partial class…

MicroMan
- 1,988
- 4
- 32
- 58
7
votes
1 answer
Haskell opposite of intersect (List)
I'm trying to get the "opposite" of intersect of two list:
like:
let all = [1..5]
let mask = [2,3]
let res = ???
-- let res = all `intersect` mask <-- reverse/opposite ?
-- I want to get [1,4,5] ?

user914584
- 571
- 8
- 15
6
votes
1 answer
How to use the Rect.intersect method.
Ive created a game where you move a rectangle and dodge other falling rectangles from the sky. Though everytime the rectangles intersect nothing happens.
if(mSquare.intersect(jSquare)){
canvas.drawColor(Color.BLACK);
or
collision =…

Kohler Fryer
- 764
- 2
- 8
- 17
6
votes
1 answer
Combining SpatialPointsDataFrame with SpatialPolygonsDataFrame error: maximum returned dense matrix size exceeded
I am trying to combine a SpatialPointsDataFrame (grid) of 1000x1000m squares over a SpatialPolygonsDataFrame (info) to aggregate all the information of the points within each grid square.
I tried the code:
combined <- intersect(info, grid)
But I…

Erik
- 73
- 1
- 8