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 8842029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:51:50+00:00 2026-06-14T10:51:50+00:00

I have 2 entities, say entity [x] and [y]. both entities are associated with

  • 0

I have 2 entities, say entity [x] and [y]. both entities are associated with some tags. entity [y] is used to search for similar [x] entities. For ex. if entity [y] consist of tags “books” and “blogs”, I want a list of all the [x] entities having both of those tags.

My table schema is:

[x] 
entity_id int    // its a foreign key from entity table  
tag varchar      // this is the tag to be matched
(one entity can have multiple tags hence multiple rows of same entity
id will be inserted)


[y]
entity_id int    // again a foreign key from entity2 table
tag varchar      // tags again
(same comment comes here too)

One more example, say I have a [y] entity_id 10, and this 10 entity_id is associated with 3 tags, say “bus”, “train” and “plane”, when I want to look up using this entity_id 10, I want a list of [x] entity_ids associated with all these 3 tags. [x] entity_id can also have additional tags too.

  • 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-14T10:51:51+00:00Added an answer on June 14, 2026 at 10:51 am

    Given a y.entity_id as a parameter, 10 in this example, this query returns every x record that doesn’t have an instance where there is a y record that doesn’t have a corresponding x record:

    SELECT
        *
    FROM
        x
    WHERE NOT EXISTS (
        SELECT *
        FROM 
            y LEFT JOIN
            x subX 
                ON subX.tag = y.tag
                AND subX.entity_id = x.entity_id
        WHERE 
            y.entity_id = 10
            AND subX.entity_id IS NULL  
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have entities Article, Page and Category. I want entity Article to
Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long
So lets say we have a couple of entities we want to persist using
Let's say, I have two tables, entities and tags. Relation between them is expressed
Say I have an entity called Request that has collections of child entities like
I have two related entities, say @Entity public class Book { @ManyToOne Shelf shelf;
I have 2 entities, let's say Client and Company (both subclass of User ).
If I have entities that inherit from a base entity (say Widgets, Gadgets, and
Say I have entities organized in a hierarchy with Parent being the root entity
I have two entities say Customer and Order which exist on their own and

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.