How to get the result for this condition?

Suppose, We have two tables:- Branch and User


BranchCode  |  BranchName  | IsActive  |
   1        |    aaa       |   0       |
   2        |    bbb       |    1      |
   3        |    ccc       |     0     |


UserId   |  Name  |
  333     |  jjjj |
  444      |  kkkk|

We want to select result as

2 - 333
2 - 444

that means, we take the branchcode for those who has isactive = 1

I am facing problem to retrieve the resultset as the table has no relation, is there a way to get the result as expected?


SELECT b.branchcode, u.UserId   
     (SELECT UserId FROM User u) u
WHERE b.IsActive = 1;

About COVID-19 | Emergency Management, How long does it take for COVID-19 symptoms to appear? Weather Underground provides local & long-range weather forecasts, weather reports, maps & tropical weather conditions for locations worldwide

SELECT CONCAT(b.branchcode,' - ', u.UserId) MemberId FROM User u,brach b WHERE b.IsActive = 1;

COVID-19 FAQs, The respiratory symptoms of COVID-19 typically appear an average of 5-6 days after exposure, but may appear in as few as 2 days or as long as 14 days after exposure, according to the U.S. Centers for Disease Control and Prevention (CDC). Even many symptomatic patients and exposed health workers who are able to get a COVID-19 test must wait nearly a week to get results. Others get results in hours. Here's why it varies so much.

You might use RIGHT OUTER JOIN as :

select concat(b.branchcode,'-',u.userid) as MemberId
  from branch b
 right outer join "user" u
    on b.isactive = 1;

2 - 333
2 - 444

p.s. user is a reserved keyword in MSSQL, so I've used table "user" instead.

SQL Fiddle Demo

Updates on Novel Corona Virus (COVID-19), The virus can cause a range of symptoms, ranging from mild illness to pneumonia. Symptoms of the disease are fever, cough, sore throat and headaches. In severe cases difficulty in breathing and deaths can occur. Re: MVC 4 How to get result with existing input condition. Jun 12, 2013 01:35 PM | goal | LINK Finally I got Anser everythings needs to understand is whatever we have controller and action result those action name we have to pass accordingly View other wise the Controller doesnt understand the which action neds to follow.

Coronavirus disease 2019 (COVID-19), Is it possible to be infected with the coronavirus disease through food? You can use the AND, OR, NOT, and IF functions to create conditional formulas. For example, the IF function uses the following arguments. Formula that uses the IF function logical_test: The condition that you want to check. value_if_true: The value to return if the condition is True. value_if_false: The value to return if the condition is False.

How to Understand Your Lab Results: MedlinePlus Lab Test , Current evidence on other coronavirus strains shows that while coronaviruses appear to be stable at low and freezing temperatures for a certain period, food hygiene and good food safety practices can prevent their transmission through food. If the pictures are held in Excel cells you can use a combination of named ranges and a dynamic image to show the image with an IF condition. In the following screenshot the images are placed in identical sized cells A1 and B1. Next, create the IF formula in cell C5: =IF(A3="show yellow","yellow","red")

What do the results of genetic tests mean?, What are false positive and false negative results? A false positive result means your test shows you have a disease or condition, but you don't  A result higher than the normal range could point to one of these conditions: Hypernatremia (too much sodium) Diabetes insipidus (the kidneys make too much urine) Dehydration (low fluid levels throughout the body) Uremia (too much urea and other waste products in the blood) Hyperglycemia (high blood sugar)

  • What happens if two branches are active and one is inactive?
  • I'm not seeing any clear relation between the Branch and User tables.
  • There is no relation so what you want is not possible.
  • @simo - The answer below proves you wrong. For the exact example dataset shown, a filter on branch and a CROSS JOIN on user is sufficient. That works fine because only one row from branch is active. What's unclear is what is meant to happen if two branches are active, or if that's even possible.
  • declare @branchcode as int; select top 1 @branchcode = branchcode from Branch where IsActive = 1; select cast(@branchcode as varchar(100)) + '-' + Name from User