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

  • Home
  • SEARCH
  • 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 9025059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:10:42+00:00 2026-06-16T06:10:42+00:00

I am not a expert query writer . Scratching my head over this one

  • 0

I am not a expert query writer . Scratching my head over this one . Can anyone help me out for this ?

Table tbF

 RecordId      MarketId

    101            1  
    102            1
    201            2
    301            3

Table tbSB

   MarketId          BMId

    1            3
    1            5
    2            1       
    2            2
    2            3
    2            4
    2            5
    3            1

Table tbFM

RecordId    BMId

101            3
102            3
102            5
201            1
201            3
201            4

Now I want a output as

   Record Id   MarketId BMId     Active 
     101        1       3          true
     101        1       5          false
     102        1       3          true
     102        1       5          true
     201        2       1          true
     201        2       2          false
     201        2       3          true
     201        2       4          true
     201        2       5          false
     301        3       1          false          

Active column –>

If the record id present is mapped to the particular BMId its true else false
RecordId belongs to a market . –> Table tbF
Each Market has certain no of BMId mapped for it –>tbSB
Each Recordid has certain no of BMId mapped for it –>tbFM

for each record if the BMid is present in tbFM then active is true
else if the BMId is mapped for records market and not for record then for that record Active is false

  • 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-16T06:10:43+00:00Added an answer on June 16, 2026 at 6:10 am
    SELECT
      f.RecordId
      , f.MId
      , s.BMId
      , Active = CASE 
        WHEN m.RecordID is null THEN 'false'
        ELSE 'true'
        END
    FROM tbF f
    INNER JOIN tbSB s ON f.MId = S.MId
    LEFT JOIN tbFM m ON m.RecordId = f.RecordID AND m.BMId = s.BMId
    

    I’ve taken Active to be determined by the existance within the tbFM table – since the expected output shown in the question matches that logic.

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

Sidebar

Related Questions

I am not that expert in SSIS. Can anybody help me out on my
I am not expert in sql and I need help with the following query.
I am not expert in ASP so i would be appreciated for the help.
I am not an expert in Git, but I have seen this done before
I'm not very expert on how processors work, but one might imagine that it
I have these two different queries. This query pulls the records from posts table
I'm not sure if this can be done. But I just wanted to check
NOTE: I am not an expert, so if you feel this question stupid/lame please
Can i get some help to clean up following query and possibly convert it
I'm not expert about css menus. But I know basic system to make css

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.