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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:45:13+00:00 2026-05-22T16:45:13+00:00

I have a set of objects in a DB which can have a number

  • 0

I have a set of objects in a DB which can have a number of boolean flags associated with them.

The flags will be pre-defined but may flags may be added or removed later. I could store them in a table with FlagID and FlagName.

Storing the values of these flags is easy – they could be saved in a simple table containing the ObjectID and the FlagID – an entry in this table would indicate a ‘set’ flag.

If I then did a query with a join, it would be easy to extract the Objects with their ‘set’ flags.

But my Symfony application (using Doctrine as the ORM) needs to get all of the ‘unset’ values in this join so it can offer checkboxes for setting them – i.e the ideal output would be

ObjectID FlagID Value
1        1      True
1        2      False
2        1      False
2        2      False
3        1      False
3        2      True

This result set would result from the following data in the database

ObjectID FlagID
1        1
3        2


FlagID   FlagName
1        Foo
2        Bar

This way, I don’t need to store all the unset flags against each Object, and thus I don’t need to worry about pre-populating the table with unset flags whenever a flag is added.

Is there a query that will generate this resultset?

  • 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-05-22T16:45:14+00:00Added an answer on May 22, 2026 at 4:45 pm

    You need something like so:

    select object.id,
           flags.id,
           object_flags.flag_id is null as has_flag
    from objects
    cross join flags
    left join object_flags
    on object_flags.object_id = objects.id
    and object_flags.flag_id = flags.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of objects which I iterate through, however I may decide
I have a set of objects in a Vector from which I'd like to
I have several objects set up in Core Data, one of which is Deck
I have a list of objects which I want to turn into a set.
I have a asp:menu object which I set up to use a SiteMapDataSource but
In a window of my WPF application I have a number of objects which
I have a number of graphics objects which I am plotting in a graphics
As the title describes, I have a set of objects - call them Allocations
I have an object which has several properties that are set when the object
I have a custom security principal object which I set in the global.asax for

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.