set-difference

MySQL: difference of two result sets

徘徊边缘 提交于 2019-11-27 00:51:57
问题 How can I get the set difference of two result sets? Say I have a result set (just one column in each): result1: 'a' 'b' 'c' result2: 'b' 'c' I want to minus what is in result1 by result2: result1 - result2 such that it equals: difference of result1 - result2: 'a' 回答1: To perform result1 - result2, you can join result1 with result2, and only output items that exist in result1. For example: SELECT DISTINCT result1.column FROM result1 LEFT JOIN result2 ON result1.column = result2.column WHERE

Difference and intersection of two arrays containing objects

*爱你&永不变心* 提交于 2019-11-26 22:25:24
I have two arrays list1 and list2 which have objects with some properties; userId is the Id or unique property: list1 = [ { userId: 1234, userName: 'XYZ' }, { userId: 1235, userName: 'ABC' }, { userId: 1236, userName: 'IJKL' }, { userId: 1237, userName: 'WXYZ' }, { userId: 1238, userName: 'LMNO' } ] list2 = [ { userId: 1235, userName: 'ABC' }, { userId: 1236, userName: 'IJKL' }, { userId: 1252, userName: 'AAAA' } ] I'm looking for an easy way to execute the following three operations: list1 operation list2 should return the intersection of elements: [ { userId: 1235, userName: 'ABC' }, {

Find the set difference between two large arrays (matrices) in Python

筅森魡賤 提交于 2019-11-26 21:48:21
问题 I have two large 2-d arrays and I'd like to find their set difference taking their rows as elements. In Matlab, the code for this would be setdiff(A,B,'rows') . The arrays are large enough that the obvious looping methods I could think of take too long. 回答1: This should work, but is currently broken in 1.6.1 due to an unavailable mergesort for the view being created. It works in the pre-release 1.7.0 version. This should be the fastest way possible, since the views don't have to copy any

Difference and intersection of two arrays containing objects

倾然丶 夕夏残阳落幕 提交于 2019-11-26 08:16:53
问题 I have two arrays list1 and list2 which have objects with some properties; userId is the Id or unique property: list1 = [ { userId: 1234, userName: \'XYZ\' }, { userId: 1235, userName: \'ABC\' }, { userId: 1236, userName: \'IJKL\' }, { userId: 1237, userName: \'WXYZ\' }, { userId: 1238, userName: \'LMNO\' } ] list2 = [ { userId: 1235, userName: \'ABC\' }, { userId: 1236, userName: \'IJKL\' }, { userId: 1252, userName: \'AAAA\' } ] I\'m looking for an easy way to execute the following three

Exclude characters from a character class

两盒软妹~` 提交于 2019-11-26 06:47:06
问题 Is there a simple way to match all characters in a class except a certain set of them? For example if in a lanaguage where I can use \\w to match the set of all unicode word characters, is there a way to just exclude a character like an underscore \"_\" from that match? Only idea that came to mind was to use negative lookahead/behind around each character but that seems more complex than necessary when I effectively just want to match a character against a positive match AND negative match.

What is the fastest or most elegant way to compute a set difference using Javascript arrays?

谁说我不能喝 提交于 2019-11-26 00:53:06
问题 Let A and B be two sets. I\'m looking for really fast or elegant ways to compute the set difference ( A - B or A \\B , depending on your preference) between them. The two sets are stored and manipulated as Javascript arrays, as the title says. Notes: Gecko-specific tricks are okay I\'d prefer sticking to native functions (but I am open to a lightweight library if it\'s way faster) I\'ve seen, but not tested, JS.Set (see previous point) Edit: I noticed a comment about sets containing duplicate

Get difference between two lists

此生再无相见时 提交于 2019-11-25 21:56:57
问题 I have two lists in Python, like these: temp1 = [\'One\', \'Two\', \'Three\', \'Four\'] temp2 = [\'One\', \'Two\'] I need to create a third list with items from the first list which aren\'t present in the second one. From the example I have to get: temp3 = [\'Three\', \'Four\'] Are there any fast ways without cycles and checking? 回答1: In [5]: list(set(temp1) - set(temp2)) Out[5]: ['Four', 'Three'] Beware that In [5]: set([1, 2]) - set([2, 3]) Out[5]: set([1]) where you might expect/want it to