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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:10:31+00:00 2026-05-23T02:10:31+00:00

I’ve got the following Tables: User 1:n UserFilter n:1 Filter Filter got an ID

  • 0

I’ve got the following Tables:

User 1:n UserFilter n:1 Filter

Filter got an ID and a Name, User got his Name as ID (don’t blame me, not my idea!).

The whole “User ‘a’ got Filters 1, 2 and 3”-Idea is being used in an ASP frontend, not important for the question.

UserFilter simply got 2 columns, User and FilterID, so if there’s a column User a – Filter 1, that means User a is using Filter 1, if there is no such column, it means he’s not.

Now I’d like to perform a SELECT query that returns every filter (there are 8 overall) for a specific user with a custom column called active.

Here’s what I got so far:

select 
    distinct f.Name, f.Type, 
    case when uf.userid = 'a' then 1 else 0 end as Active 
from filter f 
left outer join userfilter uf on f.id = uf.filterid
where uf.userid = 'a' or uf.userid is null

This will return 8 columns, some of them with Active = 0 and some with Active = 1, just as I wanted, BUT if UserFilter contains filters of multiple users, e.g.

a - 1
a - 2
b - 3
b - 7
a - 8

and I run this query for User “a” the query will only return Filter 1 as active, 2 as active, 4 5 and 6 as inactive and 8 as active, completely leaving out 3 and 7.

Any ideas?

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-05-23T02:10:32+00:00Added an answer on May 23, 2026 at 2:10 am

    The condition that userid=’a’ should be a join condition:

    select 
        distinct f.Name, f.Type, 
        case when uf.userid = 'a' then 1 else 0 end as Active 
    from filter f 
        left outer join userfilter uf on f.id = uf.filterid and uf.userid = 'a'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have just tried to save a simple *.rtf file with some websites 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.