Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:19:31+00:00 2026-06-04T17:19:31+00:00

I added six data to sorted set. Then I use zinterstore to get expected

  • 0

I added six data to sorted set. Then I use zinterstore to get expected result. but there is 0 result.

zadd la.41 41 kfc
zadd la.42 42 mdl
zadd la.43 43 apple

zadd lo.77 77 apple
zadd lo.78 78 mdl
zadd lo.79 79 kfc

zinterstore close 6 la.41 la.42 la.43 lo.77 lo.78 lo.79

expected result:

kfc
mdl
apple

actual result:

0

why ? thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:19:32+00:00Added an answer on June 4, 2026 at 5:19 pm

    It looks like you either you’re misunderstanding ZADD and creating more sets than you mean to, or you’re using intersection when you should be using union. Let’s look at both:

    Creating fewer sets

    One potential problem is that you’re creating six sets, and instead you might want to create two sets. In set notation, you’re doing this:

    la.41 = {kfc}
    la.42 = {mdl}
    la.43 = {apple}
    

    When instead you might want to be doing this:

    la = {kfc, mdl, apple}
    

    If this is what you’re intending to do, then you’ve misunderstood the ZADD command.

    ZADD takes a key, a score, and a member. You can think of the key as the name of the set, the member as the thing you’re adding to the set, and the score as the member’s position in the set.

    For example, if I run the command ZADD foo 1 a then I have created a set called foo which has the member a with a score of 1. Ignoring the score for a second, the situation is now this:

    foo = {a}
    

    If I now run ZADD foo 2 b then I’ve added the member b to the existing set foo:

    foo = {a, b}
    

    You are using a different key in each of your ZADD commands, so you’re creating a new set with each command. If you use the same key, and therefore the same set:

    ZADD la 41 kfc
    ZADD la 42 mdl
    

    You’ll end up creating a single set:

    la = {kfc, mdl}
    

    Union versus intersection

    The alternative is that you do want to create six sets, but you want the union and not the intersection.

    The union of two sets is a set containing all of the elements that were present in either of the original sets:

    {1, 2} ∪ {2, 3} = {1, 2, 3}
    

    The intersection of two sets is a set containing all of the elements that were present in both of the original sets:

    {1, 2} ∩ {2, 3} = {2}
    

    You’re creating six sets, which have no common elements and then taking the intersection of them:

    {kfc} ∩ {mdl} ∩ {apple} ∩ {kfc} ∩ {mdl} ∩ {apple} = {}
    

    If you were taking the union instead you would end up with all of the elements in the resulting set:

    {kfc} ∪ {mdl} ∪ {apple} ∪ {kfc} ∪ {mdl} ∪ {apple} = {kfc, mdl, apple}
    

    You can achieve this by using the ZUNIONSTORE Redis command instead of ZINTERSTORE.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i added this line.but it gives error.how to import it? import org.andengine.opengl.texture.atlas.TextureAtlas;
I added a new new application and am trying to use Open Graph to
I added zero code to my gwt.xml <inherits name=org.miller.gwt.Sound></inherits> and then added 'gwt-sound.jar' to
Location added to table. But missing latitude/longitude. So no marker added to the map.
I added this code to the head but when I try to post something
I added the QuartzCore framework to my ios 5.0 project and then tried [self
I added <script type=text/javasript src=<?=base_url()?>js/jquery-1.7.2.min.js></script> in application/views/templatess/header.php and to post data to Controller using
I added in the @user = User.new line to make sure it isn't nil.
I added the following code segment to my project to force the JScrollPane automatically
I added a new website language to a TYPO3 project. The new website language

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.